├── .gitignore ├── CPPMLBasics.sln ├── Data ├── MNIST │ ├── t10k-images.idx3-ubyte │ ├── t10k-labels.idx1-ubyte │ ├── train-images.idx3-ubyte │ └── train-labels.idx1-ubyte └── README.txt ├── Demo ├── Demo.vcxproj ├── Demo.vcxproj.filters ├── Demo.vcxproj.user ├── dxcompiler.dll ├── dxil.dll ├── imgui.ini ├── imgui │ ├── .editorconfig │ ├── .gitattributes │ ├── .github │ │ ├── FUNDING.yml │ │ ├── issue_template.md │ │ ├── pull_request_template.md │ │ └── workflows │ │ │ ├── build.yml │ │ │ ├── scheduled.yml │ │ │ └── static-analysis.yml │ ├── .gitignore │ ├── LICENSE.txt │ ├── backends │ │ ├── imgui_impl_allegro5.cpp │ │ ├── imgui_impl_allegro5.h │ │ ├── imgui_impl_android.cpp │ │ ├── imgui_impl_android.h │ │ ├── imgui_impl_dx10.cpp │ │ ├── imgui_impl_dx10.h │ │ ├── imgui_impl_dx11.cpp │ │ ├── imgui_impl_dx11.h │ │ ├── imgui_impl_dx12.cpp │ │ ├── imgui_impl_dx12.h │ │ ├── imgui_impl_dx9.cpp │ │ ├── imgui_impl_dx9.h │ │ ├── imgui_impl_glfw.cpp │ │ ├── imgui_impl_glfw.h │ │ ├── imgui_impl_glut.cpp │ │ ├── imgui_impl_glut.h │ │ ├── imgui_impl_metal.h │ │ ├── imgui_impl_metal.mm │ │ ├── imgui_impl_opengl2.cpp │ │ ├── imgui_impl_opengl2.h │ │ ├── imgui_impl_opengl3.cpp │ │ ├── imgui_impl_opengl3.h │ │ ├── imgui_impl_opengl3_loader.h │ │ ├── imgui_impl_osx.h │ │ ├── imgui_impl_osx.mm │ │ ├── imgui_impl_sdl2.cpp │ │ ├── imgui_impl_sdl2.h │ │ ├── imgui_impl_sdl3.cpp │ │ ├── imgui_impl_sdl3.h │ │ ├── imgui_impl_sdlrenderer.cpp │ │ ├── imgui_impl_sdlrenderer.h │ │ ├── imgui_impl_vulkan.cpp │ │ ├── imgui_impl_vulkan.h │ │ ├── imgui_impl_wgpu.cpp │ │ ├── imgui_impl_wgpu.h │ │ ├── imgui_impl_win32.cpp │ │ ├── imgui_impl_win32.h │ │ └── vulkan │ │ │ ├── generate_spv.sh │ │ │ ├── glsl_shader.frag │ │ │ └── glsl_shader.vert │ ├── docs │ │ ├── BACKENDS.md │ │ ├── CHANGELOG.txt │ │ ├── CONTRIBUTING.md │ │ ├── EXAMPLES.md │ │ ├── FAQ.md │ │ ├── FONTS.md │ │ ├── README.md │ │ └── TODO.txt │ ├── examples │ │ ├── README.txt │ │ ├── example_allegro5 │ │ │ ├── README.md │ │ │ ├── example_allegro5.vcxproj │ │ │ ├── example_allegro5.vcxproj.filters │ │ │ ├── imconfig_allegro5.h │ │ │ └── main.cpp │ │ ├── example_android_opengl3 │ │ │ ├── CMakeLists.txt │ │ │ ├── android │ │ │ │ ├── .gitignore │ │ │ │ ├── app │ │ │ │ │ ├── build.gradle │ │ │ │ │ └── src │ │ │ │ │ │ └── main │ │ │ │ │ │ ├── AndroidManifest.xml │ │ │ │ │ │ └── java │ │ │ │ │ │ └── MainActivity.kt │ │ │ │ ├── build.gradle │ │ │ │ └── settings.gradle │ │ │ └── main.cpp │ │ ├── example_apple_metal │ │ │ ├── README.md │ │ │ ├── example_apple_metal.xcodeproj │ │ │ │ └── project.pbxproj │ │ │ ├── iOS │ │ │ │ ├── Info-iOS.plist │ │ │ │ └── LaunchScreen.storyboard │ │ │ ├── macOS │ │ │ │ ├── Info-macOS.plist │ │ │ │ └── MainMenu.storyboard │ │ │ └── main.mm │ │ ├── example_apple_opengl2 │ │ │ ├── example_apple_opengl2.xcodeproj │ │ │ │ └── project.pbxproj │ │ │ └── main.mm │ │ ├── example_emscripten_wgpu │ │ │ ├── Makefile │ │ │ ├── README.md │ │ │ └── main.cpp │ │ ├── example_glfw_metal │ │ │ ├── Makefile │ │ │ └── main.mm │ │ ├── example_glfw_opengl2 │ │ │ ├── Makefile │ │ │ ├── build_win32.bat │ │ │ ├── example_glfw_opengl2.vcxproj │ │ │ ├── example_glfw_opengl2.vcxproj.filters │ │ │ └── main.cpp │ │ ├── example_glfw_opengl3 │ │ │ ├── Makefile │ │ │ ├── Makefile.emscripten │ │ │ ├── build_win32.bat │ │ │ ├── example_glfw_opengl3.vcxproj │ │ │ ├── example_glfw_opengl3.vcxproj.filters │ │ │ └── main.cpp │ │ ├── example_glfw_vulkan │ │ │ ├── CMakeLists.txt │ │ │ ├── build_win32.bat │ │ │ ├── build_win64.bat │ │ │ ├── example_glfw_vulkan.vcxproj │ │ │ ├── example_glfw_vulkan.vcxproj.filters │ │ │ └── main.cpp │ │ ├── example_glut_opengl2 │ │ │ ├── Makefile │ │ │ ├── example_glut_opengl2.vcxproj │ │ │ ├── example_glut_opengl2.vcxproj.filters │ │ │ └── main.cpp │ │ ├── example_null │ │ │ ├── Makefile │ │ │ ├── build_win32.bat │ │ │ └── main.cpp │ │ ├── example_sdl2_directx11 │ │ │ ├── build_win32.bat │ │ │ ├── example_sdl2_directx11.vcxproj │ │ │ ├── example_sdl2_directx11.vcxproj.filters │ │ │ └── main.cpp │ │ ├── example_sdl2_metal │ │ │ ├── Makefile │ │ │ └── main.mm │ │ ├── example_sdl2_opengl2 │ │ │ ├── Makefile │ │ │ ├── README.md │ │ │ ├── build_win32.bat │ │ │ ├── example_sdl2_opengl2.vcxproj │ │ │ ├── example_sdl2_opengl2.vcxproj.filters │ │ │ └── main.cpp │ │ ├── example_sdl2_opengl3 │ │ │ ├── Makefile │ │ │ ├── Makefile.emscripten │ │ │ ├── README.md │ │ │ ├── build_win32.bat │ │ │ ├── example_sdl2_opengl3.vcxproj │ │ │ ├── example_sdl2_opengl3.vcxproj.filters │ │ │ └── main.cpp │ │ ├── example_sdl2_sdlrenderer │ │ │ ├── Makefile │ │ │ ├── README.md │ │ │ ├── build_win32.bat │ │ │ ├── example_sdl2_sdlrenderer.vcxproj │ │ │ ├── example_sdl2_sdlrenderer.vcxproj.filters │ │ │ └── main.cpp │ │ ├── example_sdl2_vulkan │ │ │ ├── build_win32.bat │ │ │ ├── example_sdl2_vulkan.vcxproj │ │ │ ├── example_sdl2_vulkan.vcxproj.filters │ │ │ └── main.cpp │ │ ├── example_sdl3_opengl3 │ │ │ ├── Makefile │ │ │ ├── Makefile.emscripten │ │ │ ├── README.md │ │ │ ├── build_win32.bat │ │ │ ├── example_sdl3_opengl3.vcxproj │ │ │ ├── example_sdl3_opengl3.vcxproj.filters │ │ │ └── main.cpp │ │ ├── example_win32_directx10 │ │ │ ├── build_win32.bat │ │ │ ├── example_win32_directx10.vcxproj │ │ │ ├── example_win32_directx10.vcxproj.filters │ │ │ └── main.cpp │ │ ├── example_win32_directx11 │ │ │ ├── build_win32.bat │ │ │ ├── example_win32_directx11.vcxproj │ │ │ ├── example_win32_directx11.vcxproj.filters │ │ │ └── main.cpp │ │ ├── example_win32_directx12 │ │ │ ├── build_win32.bat │ │ │ ├── example_win32_directx12.vcxproj │ │ │ ├── example_win32_directx12.vcxproj.filters │ │ │ └── main.cpp │ │ ├── example_win32_directx9 │ │ │ ├── build_win32.bat │ │ │ ├── example_win32_directx9.vcxproj │ │ │ ├── example_win32_directx9.vcxproj.filters │ │ │ └── main.cpp │ │ ├── imgui_examples.sln │ │ └── libs │ │ │ ├── emscripten │ │ │ ├── emscripten_mainloop_stub.h │ │ │ └── shell_minimal.html │ │ │ ├── glfw │ │ │ ├── COPYING.txt │ │ │ ├── include │ │ │ │ └── GLFW │ │ │ │ │ ├── glfw3.h │ │ │ │ │ └── glfw3native.h │ │ │ ├── lib-vc2010-32 │ │ │ │ └── glfw3.lib │ │ │ └── lib-vc2010-64 │ │ │ │ └── glfw3.lib │ │ │ └── usynergy │ │ │ ├── README.txt │ │ │ ├── uSynergy.c │ │ │ └── uSynergy.h │ ├── imconfig.h │ ├── imgui.cpp │ ├── imgui.h │ ├── imgui_demo.cpp │ ├── imgui_draw.cpp │ ├── imgui_internal.h │ ├── imgui_tables.cpp │ ├── imgui_widgets.cpp │ ├── imstb_rectpack.h │ ├── imstb_textedit.h │ ├── imstb_truetype.h │ └── misc │ │ ├── README.txt │ │ ├── cpp │ │ ├── README.txt │ │ ├── imgui_stdlib.cpp │ │ └── imgui_stdlib.h │ │ ├── debuggers │ │ ├── README.txt │ │ ├── imgui.gdb │ │ ├── imgui.natstepfilter │ │ └── imgui.natvis │ │ ├── fonts │ │ ├── Cousine-Regular.ttf │ │ ├── DroidSans.ttf │ │ ├── Karla-Regular.ttf │ │ ├── ProggyClean.ttf │ │ ├── ProggyTiny.ttf │ │ ├── Roboto-Medium.ttf │ │ └── binary_to_compressed_c.cpp │ │ ├── freetype │ │ ├── README.md │ │ ├── imgui_freetype.cpp │ │ └── imgui_freetype.h │ │ └── single_file │ │ └── imgui_single_file.h ├── main.cpp └── mnist │ ├── DX12Utils │ ├── CompileShaders.h │ ├── CompileShaders_dxc.cpp │ ├── CompileShaders_fxc.cpp │ ├── DelayedReleaseTracker.h │ ├── FileCache.cpp │ ├── FileCache.h │ ├── HeapAllocationTracker.h │ ├── ParseCSV.h │ ├── ReadbackHelper.h │ ├── SRGB.h │ ├── TextureCache.cpp │ ├── TextureCache.h │ ├── dxutils.cpp │ ├── dxutils.h │ ├── logfn.h │ ├── stb │ │ ├── LICENSE │ │ ├── stb_image.h │ │ └── stb_image_write.h │ └── tinyexr │ │ ├── README.md │ │ ├── deps │ │ └── miniz │ │ │ ├── LICENSE │ │ │ ├── miniz.c │ │ │ ├── miniz.h │ │ │ └── readme.md │ │ └── tinyexr.h │ ├── Gigi │ ├── 0.png │ ├── 1.png │ ├── 2.png │ ├── 3.png │ ├── 4.png │ ├── 5.png │ ├── 6.png │ ├── 7.png │ ├── 8.png │ ├── 9.png │ ├── Backprop_Weights.bin │ ├── CalculateExtents.hlsl │ ├── HiddenLayer.hlsl │ ├── LICENSE.txt │ ├── OutputLayer.hlsl │ ├── Presentation.hlsl │ ├── Screenshot.png │ ├── Technique.json │ ├── draw.hlsl │ ├── instructions.png │ ├── mnist.gg │ ├── mnist.gguser │ └── shrink.hlsl │ ├── assets │ ├── 0.png │ ├── 1.png │ ├── 2.png │ ├── 3.png │ ├── 4.png │ ├── 5.png │ ├── 6.png │ ├── 7.png │ ├── 8.png │ ├── 9.png │ ├── Backprop_Weights.bin │ └── instructions.png │ ├── private │ ├── technique.cpp │ └── technique.h │ ├── public │ ├── all.h │ ├── imgui.h │ ├── pythoninterface.h │ └── technique.h │ ├── readme.txt │ └── shaders │ ├── CalculateExtents.hlsl │ ├── HiddenLayer.hlsl │ ├── OutputLayer.hlsl │ ├── Presentation.hlsl │ ├── draw.hlsl │ └── shrink.hlsl ├── Exercises ├── 1_LogicGates │ ├── Exercise Set 1 - Instructions.docx │ └── Exercise Set 1 - Solutions.docx ├── 2_FiniteDifferences │ ├── Exercise Set 2 - Instructions.docx │ ├── Exercise Set 2 - Solutions.docx │ └── FiniteDifferences │ │ ├── FiniteDifferences.sln │ │ ├── FiniteDifferences.vcxproj │ │ ├── FiniteDifferences.vcxproj.filters │ │ ├── FiniteDifferences.vcxproj.user │ │ └── main.cpp ├── 3_DualNumbers │ ├── DualNumbers │ │ ├── DualNumbers.sln │ │ ├── DualNumbers.vcxproj │ │ ├── DualNumbers.vcxproj.filters │ │ ├── DualNumbers.vcxproj.user │ │ └── main.cpp │ ├── Exercise Set 3 - Instructions.docx │ └── Exercise Set 3 - Solutions.docx └── 4_Backprop │ ├── ChainRule │ ├── ChainRule.sln │ ├── ChainRule.vcxproj │ ├── ChainRule.vcxproj.filters │ ├── ChainRule.vcxproj.user │ └── main.cpp │ ├── Exercise Set 4 - Instructions.docx │ └── Exercise Set 4 - Solutions.docx ├── LICENSE.txt ├── Machina Presentation 2023 - ML Intro For Game Devs.pptx ├── README.md ├── Training ├── DataSet.cpp ├── DataSet.h ├── DualNumber.h ├── GetGradient_BackProp.cpp ├── GetGradient_DualNumbers.cpp ├── GetGradient_FiniteDifferences.cpp ├── NN.h ├── Settings.h ├── StackPoolAllocator.h ├── Training.vcxproj ├── Training.vcxproj.filters ├── Training.vcxproj.user ├── main.cpp └── out │ ├── Backprop_Accuracy.csv │ ├── Backprop_Weights.bin │ └── Backprop_Weights.csv └── logo └── SEED.jpg /.gitignore: -------------------------------------------------------------------------------- 1 | **/.vs/ 2 | **/x64/Debug/ 3 | **/x64/Release/ 4 | Data/Training/ 5 | Data/Testing/ -------------------------------------------------------------------------------- /CPPMLBasics.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.5.33424.131 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Training", "Training\Training.vcxproj", "{C6A2A337-7D61-490C-8D61-DE6CE9C5938F}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Demo", "Demo\Demo.vcxproj", "{F97A1008-B8A9-417F-A65F-3EDEBD324A92}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|x64 = Debug|x64 13 | Release|x64 = Release|x64 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {C6A2A337-7D61-490C-8D61-DE6CE9C5938F}.Debug|x64.ActiveCfg = Debug|x64 17 | {C6A2A337-7D61-490C-8D61-DE6CE9C5938F}.Debug|x64.Build.0 = Debug|x64 18 | {C6A2A337-7D61-490C-8D61-DE6CE9C5938F}.Release|x64.ActiveCfg = Release|x64 19 | {C6A2A337-7D61-490C-8D61-DE6CE9C5938F}.Release|x64.Build.0 = Release|x64 20 | {F97A1008-B8A9-417F-A65F-3EDEBD324A92}.Debug|x64.ActiveCfg = Debug|x64 21 | {F97A1008-B8A9-417F-A65F-3EDEBD324A92}.Debug|x64.Build.0 = Debug|x64 22 | {F97A1008-B8A9-417F-A65F-3EDEBD324A92}.Release|x64.ActiveCfg = Release|x64 23 | {F97A1008-B8A9-417F-A65F-3EDEBD324A92}.Release|x64.Build.0 = Release|x64 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {2AC7CDD1-6EFC-458A-8F24-5BCC00EFE92C} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /Data/MNIST/t10k-images.idx3-ubyte: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronicarts/cpp-ml-intro/682222d9993d122749723b54d8d6064d6117288a/Data/MNIST/t10k-images.idx3-ubyte -------------------------------------------------------------------------------- /Data/MNIST/train-images.idx3-ubyte: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronicarts/cpp-ml-intro/682222d9993d122749723b54d8d6064d6117288a/Data/MNIST/train-images.idx3-ubyte -------------------------------------------------------------------------------- /Data/MNIST/train-labels.idx1-ubyte: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronicarts/cpp-ml-intro/682222d9993d122749723b54d8d6064d6117288a/Data/MNIST/train-labels.idx1-ubyte -------------------------------------------------------------------------------- /Data/README.txt: -------------------------------------------------------------------------------- 1 | the contents of the mnist folder came from: 2 | http://yann.lecun.com/exdb/mnist/ 3 | 4 | The Testing and Training folder contents are made by extracting the images from those mnist data files, 5 | which happens as part of the training process, to show the input to training. -------------------------------------------------------------------------------- /Demo/Demo.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Demo/dxcompiler.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronicarts/cpp-ml-intro/682222d9993d122749723b54d8d6064d6117288a/Demo/dxcompiler.dll -------------------------------------------------------------------------------- /Demo/dxil.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronicarts/cpp-ml-intro/682222d9993d122749723b54d8d6064d6117288a/Demo/dxil.dll -------------------------------------------------------------------------------- /Demo/imgui.ini: -------------------------------------------------------------------------------- 1 | [Window][Debug##Default] 2 | Pos=60,60 3 | Size=400,400 4 | Collapsed=0 5 | 6 | [Window][MNIST] 7 | Pos=684,190 8 | Size=494,500 9 | Collapsed=0 10 | 11 | -------------------------------------------------------------------------------- /Demo/imgui/.editorconfig: -------------------------------------------------------------------------------- 1 | # See http://editorconfig.org to read about the EditorConfig format. 2 | # - In theory automatically supported by VS2017+ and most common IDE or text editors. 3 | # - In practice VS2019-VS2022 stills don't trim trailing whitespaces correctly :( 4 | # - Suggest installing this to trim whitespaces: 5 | # GitHub https://github.com/madskristensen/TrailingWhitespace 6 | # VS2019 https://marketplace.visualstudio.com/items?itemName=MadsKristensen.TrailingWhitespaceVisualizer 7 | # VS2022 https://marketplace.visualstudio.com/items?itemName=MadsKristensen.TrailingWhitespace64 8 | # (in spite of its name doesn't only visualize but also trims) 9 | # - Alternative for older VS2010 to VS2015: https://marketplace.visualstudio.com/items?itemName=EditorConfigTeam.EditorConfig 10 | 11 | # top-most EditorConfig file 12 | root = true 13 | 14 | # Default settings: 15 | # Use 4 spaces as indentation 16 | [*] 17 | indent_style = space 18 | indent_size = 4 19 | insert_final_newline = true 20 | trim_trailing_whitespace = true 21 | 22 | [imstb_*] 23 | indent_size = 3 24 | trim_trailing_whitespace = false 25 | 26 | [Makefile] 27 | indent_style = tab 28 | indent_size = 4 29 | -------------------------------------------------------------------------------- /Demo/imgui/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | 3 | *.c text 4 | *.cpp text 5 | *.h text 6 | *.m text 7 | *.mm text 8 | *.md text 9 | *.txt text 10 | *.html text 11 | *.bat text 12 | *.frag text 13 | *.vert text 14 | *.mkb text 15 | *.icf text 16 | 17 | *.sln text eol=crlf 18 | *.vcxproj text eol=crlf 19 | *.vcxproj.filters text eol=crlf 20 | *.natvis text eol=crlf 21 | 22 | Makefile text eol=lf 23 | *.sh text eol=lf 24 | *.pbxproj text eol=lf 25 | *.storyboard text eol=lf 26 | *.plist text eol=lf 27 | 28 | *.png binary 29 | *.ttf binary 30 | *.lib binary 31 | -------------------------------------------------------------------------------- /Demo/imgui/.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | custom: ['https://github.com/ocornut/imgui/wiki/Sponsors'] 2 | -------------------------------------------------------------------------------- /Demo/imgui/.github/issue_template.md: -------------------------------------------------------------------------------- 1 | (Click "Preview" above ^ to turn URL into clickable links) 2 | 3 | 1. FOR FIRST-TIME USERS ISSUES COMPILING/LINKING/RUNNING or LOADING FONTS, please use [GitHub Discussions](https://github.com/ocornut/imgui/discussions). 4 | 5 | 2. PLEASE CAREFULLY READ: [FAQ](https://github.com/ocornut/imgui/blob/master/docs/FAQ.md) 6 | 7 | 3. PLEASE CAREFULLY READ: [Contributing Guidelines](https://github.com/ocornut/imgui/blob/master/docs/CONTRIBUTING.md) 8 | 9 | 4. PLEASE MAKE SURE that you have: read the FAQ; explored the contents of `ShowDemoWindow()` including the Examples menu; searched among Issues; used your IDE to search for keywords in all sources and text files; and read the links above. 10 | 11 | 5. Be mindful that messages are being sent to the e-mail box of "Watching" users. Try to proof-read your messages before sending them. Edits are not seen by those users. 12 | 13 | 6. Delete points 1-6 and PLEASE FILL THE TEMPLATE BELOW before submitting your issue. 14 | 15 | Thank you! 16 | 17 | ---- 18 | 19 | _(you may also go to Demo>About Window, and click "Config/Build Information" to obtain a bunch of detailed information that you can paste here)_ 20 | 21 | **Version/Branch of Dear ImGui:** 22 | 23 | Version: XXX 24 | Branch: XXX _(master/viewport/docking/etc.)_ 25 | 26 | **Back-end/Renderer/Compiler/OS** 27 | 28 | Back-ends: imgui_impl_XXX.cpp + imgui_impl_XXX.cpp _(or specify if using a custom engine/back-end)_ 29 | Compiler: XXX _(if the question is related to building or platform specific features)_ 30 | Operating System: XXX 31 | 32 | **My Issue/Question:** 33 | 34 | XXX _(please provide as much context as possible)_ 35 | 36 | **Screenshots/Video** 37 | 38 | XXX _(you can drag files here)_ 39 | 40 | **Standalone, minimal, complete and verifiable example:** _(see https://github.com/ocornut/imgui/issues/2261)_ 41 | ``` 42 | // Here's some code anyone can copy and paste to reproduce your issue 43 | ImGui::Begin("Example Bug"); 44 | MoreCodeToExplainMyIssue(); 45 | ImGui::End(); 46 | ``` 47 | -------------------------------------------------------------------------------- /Demo/imgui/.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | (Click "Preview" to turn any http URL into a clickable link) 2 | 3 | 1. PLEASE CAREFULLY READ: [Contributing Guidelines](https://github.com/ocornut/imgui/blob/master/docs/CONTRIBUTING.md) 4 | 5 | 2. Clear this template before submitting your PR. 6 | 7 | -------------------------------------------------------------------------------- /Demo/imgui/.github/workflows/scheduled.yml: -------------------------------------------------------------------------------- 1 | # 2 | # This is a dummy workflow used to trigger scheduled builds. Forked repositories most likely should disable this 3 | # workflow to avoid daily builds of inactive repositories. 4 | # 5 | name: scheduled 6 | 7 | on: 8 | schedule: 9 | - cron: '0 9 * * *' 10 | 11 | jobs: 12 | scheduled: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - run: exit 0 16 | -------------------------------------------------------------------------------- /Demo/imgui/.github/workflows/static-analysis.yml: -------------------------------------------------------------------------------- 1 | name: static-analysis 2 | 3 | on: 4 | workflow_run: 5 | # Perform static analysis together with build workflow. Build triggers of "build" workflow do not need to be repeated here. 6 | workflows: 7 | - build 8 | types: 9 | - requested 10 | 11 | jobs: 12 | PVS-Studio: 13 | runs-on: ubuntu-22.04 14 | steps: 15 | - uses: actions/checkout@v3 16 | with: 17 | fetch-depth: 1 18 | 19 | - name: Install Dependencies 20 | env: 21 | # The Secret variable setup in GitHub must be in format: "name_or_email key", on a single line 22 | PVS_STUDIO_LICENSE: ${{ secrets.PVS_STUDIO_LICENSE }} 23 | run: | 24 | if [[ "$PVS_STUDIO_LICENSE" != "" ]]; 25 | then 26 | wget -q https://files.viva64.com/etc/pubkey.txt 27 | sudo apt-key add pubkey.txt 28 | sudo wget -O /etc/apt/sources.list.d/viva64.list https://files.viva64.com/etc/viva64.list 29 | sudo apt-get update 30 | sudo apt-get install -y pvs-studio 31 | pvs-studio-analyzer credentials -o pvs-studio.lic $PVS_STUDIO_LICENSE 32 | fi 33 | 34 | - name: PVS-Studio static analysis 35 | run: | 36 | if [[ ! -f pvs-studio.lic ]]; 37 | then 38 | echo "PVS Studio license is missing. No analysis will be performed." 39 | echo "If you have a PVS Studio license please create a project secret named PVS_STUDIO_LICENSE with your license." 40 | echo "You may use a free license. More information at https://www.viva64.com/en/b/0457/" 41 | exit 0 42 | fi 43 | cd examples/example_null 44 | pvs-studio-analyzer trace -- make WITH_EXTRA_WARNINGS=1 45 | pvs-studio-analyzer analyze -e ../../imstb_rectpack.h -e ../../imstb_textedit.h -e ../../imstb_truetype.h -l ../../pvs-studio.lic -o pvs-studio.log 46 | plog-converter -a 'GA:1,2;OP:1' -d V1071 -t errorfile -w pvs-studio.log 47 | -------------------------------------------------------------------------------- /Demo/imgui/.gitignore: -------------------------------------------------------------------------------- 1 | ## OSX artifacts 2 | .DS_Store 3 | 4 | ## Dear ImGui artifacts 5 | imgui.ini 6 | 7 | ## General build artifacts 8 | *.o 9 | *.obj 10 | *.exe 11 | examples/build/* 12 | examples/*/Debug/* 13 | examples/*/Release/* 14 | examples/*/x64/* 15 | 16 | ## Visual Studio artifacts 17 | .vs 18 | ipch 19 | *.opensdf 20 | *.log 21 | *.pdb 22 | *.ilk 23 | *.user 24 | *.sdf 25 | *.suo 26 | *.VC.db 27 | *.VC.VC.opendb 28 | 29 | ## Getting files created in JSON/Schemas/Catalog/ from a VS2022 update 30 | JSON/ 31 | 32 | ## Commonly used CMake directories 33 | /build*/ 34 | 35 | ## Xcode artifacts 36 | project.xcworkspace 37 | xcuserdata 38 | 39 | ## Emscripten artifacts 40 | examples/*.o.tmp 41 | examples/*.out.js 42 | examples/*.out.wasm 43 | examples/example_glfw_opengl3/web/* 44 | examples/example_sdl2_opengl3/web/* 45 | examples/example_emscripten_wgpu/web/* 46 | 47 | ## JetBrains IDE artifacts 48 | .idea 49 | cmake-build-* 50 | 51 | ## Unix executables from our example Makefiles 52 | examples/example_glfw_metal/example_glfw_metal 53 | examples/example_glfw_opengl2/example_glfw_opengl2 54 | examples/example_glfw_opengl3/example_glfw_opengl3 55 | examples/example_glut_opengl2/example_glut_opengl2 56 | examples/example_null/example_null 57 | examples/example_sdl2_metal/example_sdl2_metal 58 | examples/example_sdl2_opengl2/example_sdl2_opengl2 59 | examples/example_sdl2_opengl3/example_sdl2_opengl3 60 | examples/example_sdl2_sdlrenderer/example_sdl2_sdlrenderer 61 | -------------------------------------------------------------------------------- /Demo/imgui/LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014-2023 Omar Cornut 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Demo/imgui/backends/imgui_impl_allegro5.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Renderer + Platform Backend for Allegro 5 2 | // (Info: Allegro 5 is a cross-platform general purpose library for handling windows, inputs, graphics, etc.) 3 | 4 | // Implemented features: 5 | // [X] Renderer: User texture binding. Use 'ALLEGRO_BITMAP*' as ImTextureID. Read the FAQ about ImTextureID! 6 | // [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy ALLEGRO_KEY_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set] 7 | // [X] Platform: Clipboard support (from Allegro 5.1.12) 8 | // [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. 9 | // Issues: 10 | // [ ] Renderer: The renderer is suboptimal as we need to unindex our buffers and convert vertices manually. 11 | // [ ] Platform: Missing gamepad support. 12 | 13 | // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. 14 | // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. 15 | // If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. 16 | // Read online: https://github.com/ocornut/imgui/tree/master/docs 17 | 18 | #pragma once 19 | #include "imgui.h" // IMGUI_IMPL_API 20 | 21 | struct ALLEGRO_DISPLAY; 22 | union ALLEGRO_EVENT; 23 | 24 | IMGUI_IMPL_API bool ImGui_ImplAllegro5_Init(ALLEGRO_DISPLAY* display); 25 | IMGUI_IMPL_API void ImGui_ImplAllegro5_Shutdown(); 26 | IMGUI_IMPL_API void ImGui_ImplAllegro5_NewFrame(); 27 | IMGUI_IMPL_API void ImGui_ImplAllegro5_RenderDrawData(ImDrawData* draw_data); 28 | IMGUI_IMPL_API bool ImGui_ImplAllegro5_ProcessEvent(ALLEGRO_EVENT* event); 29 | 30 | // Use if you want to reset your rendering device without losing Dear ImGui state. 31 | IMGUI_IMPL_API bool ImGui_ImplAllegro5_CreateDeviceObjects(); 32 | IMGUI_IMPL_API void ImGui_ImplAllegro5_InvalidateDeviceObjects(); 33 | -------------------------------------------------------------------------------- /Demo/imgui/backends/imgui_impl_android.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Platform Binding for Android native app 2 | // This needs to be used along with the OpenGL 3 Renderer (imgui_impl_opengl3) 3 | 4 | // Implemented features: 5 | // [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy AKEYCODE_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set] 6 | // Missing features: 7 | // [ ] Platform: Clipboard support. 8 | // [ ] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. 9 | // [ ] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. FIXME: Check if this is even possible with Android. 10 | // Important: 11 | // - Consider using SDL or GLFW backend on Android, which will be more full-featured than this. 12 | // - FIXME: On-screen keyboard currently needs to be enabled by the application (see examples/ and issue #3446) 13 | // - FIXME: Unicode character inputs needs to be passed by Dear ImGui by the application (see examples/ and issue #3446) 14 | 15 | // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. 16 | // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. 17 | // If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. 18 | // Read online: https://github.com/ocornut/imgui/tree/master/docs 19 | 20 | #pragma once 21 | 22 | struct ANativeWindow; 23 | struct AInputEvent; 24 | 25 | IMGUI_IMPL_API bool ImGui_ImplAndroid_Init(ANativeWindow* window); 26 | IMGUI_IMPL_API int32_t ImGui_ImplAndroid_HandleInputEvent(AInputEvent* input_event); 27 | IMGUI_IMPL_API void ImGui_ImplAndroid_Shutdown(); 28 | IMGUI_IMPL_API void ImGui_ImplAndroid_NewFrame(); 29 | -------------------------------------------------------------------------------- /Demo/imgui/backends/imgui_impl_dx10.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Renderer Backend for DirectX10 2 | // This needs to be used along with a Platform Backend (e.g. Win32) 3 | 4 | // Implemented features: 5 | // [X] Renderer: User texture binding. Use 'ID3D10ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID! 6 | // [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices. 7 | 8 | // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. 9 | // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. 10 | // If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. 11 | // Read online: https://github.com/ocornut/imgui/tree/master/docs 12 | 13 | #pragma once 14 | #include "imgui.h" // IMGUI_IMPL_API 15 | 16 | struct ID3D10Device; 17 | 18 | IMGUI_IMPL_API bool ImGui_ImplDX10_Init(ID3D10Device* device); 19 | IMGUI_IMPL_API void ImGui_ImplDX10_Shutdown(); 20 | IMGUI_IMPL_API void ImGui_ImplDX10_NewFrame(); 21 | IMGUI_IMPL_API void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data); 22 | 23 | // Use if you want to reset your rendering device without losing Dear ImGui state. 24 | IMGUI_IMPL_API void ImGui_ImplDX10_InvalidateDeviceObjects(); 25 | IMGUI_IMPL_API bool ImGui_ImplDX10_CreateDeviceObjects(); 26 | -------------------------------------------------------------------------------- /Demo/imgui/backends/imgui_impl_dx11.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Renderer Backend for DirectX11 2 | // This needs to be used along with a Platform Backend (e.g. Win32) 3 | 4 | // Implemented features: 5 | // [X] Renderer: User texture binding. Use 'ID3D11ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID! 6 | // [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices. 7 | 8 | // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. 9 | // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. 10 | // If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. 11 | // Read online: https://github.com/ocornut/imgui/tree/master/docs 12 | 13 | #pragma once 14 | #include "imgui.h" // IMGUI_IMPL_API 15 | 16 | struct ID3D11Device; 17 | struct ID3D11DeviceContext; 18 | 19 | IMGUI_IMPL_API bool ImGui_ImplDX11_Init(ID3D11Device* device, ID3D11DeviceContext* device_context); 20 | IMGUI_IMPL_API void ImGui_ImplDX11_Shutdown(); 21 | IMGUI_IMPL_API void ImGui_ImplDX11_NewFrame(); 22 | IMGUI_IMPL_API void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data); 23 | 24 | // Use if you want to reset your rendering device without losing Dear ImGui state. 25 | IMGUI_IMPL_API void ImGui_ImplDX11_InvalidateDeviceObjects(); 26 | IMGUI_IMPL_API bool ImGui_ImplDX11_CreateDeviceObjects(); 27 | -------------------------------------------------------------------------------- /Demo/imgui/backends/imgui_impl_dx12.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Renderer Backend for DirectX12 2 | // This needs to be used along with a Platform Backend (e.g. Win32) 3 | 4 | // Implemented features: 5 | // [X] Renderer: User texture binding. Use 'D3D12_GPU_DESCRIPTOR_HANDLE' as ImTextureID. Read the FAQ about ImTextureID! 6 | // [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices. 7 | 8 | // Important: to compile on 32-bit systems, this backend requires code to be compiled with '#define ImTextureID ImU64'. 9 | // See imgui_impl_dx12.cpp file for details. 10 | 11 | // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. 12 | // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. 13 | // If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. 14 | // Read online: https://github.com/ocornut/imgui/tree/master/docs 15 | 16 | #pragma once 17 | #include "imgui.h" // IMGUI_IMPL_API 18 | #include // DXGI_FORMAT 19 | 20 | struct ID3D12Device; 21 | struct ID3D12DescriptorHeap; 22 | struct ID3D12GraphicsCommandList; 23 | struct D3D12_CPU_DESCRIPTOR_HANDLE; 24 | struct D3D12_GPU_DESCRIPTOR_HANDLE; 25 | 26 | // cmd_list is the command list that the implementation will use to render imgui draw lists. 27 | // Before calling the render function, caller must prepare cmd_list by resetting it and setting the appropriate 28 | // render target and descriptor heap that contains font_srv_cpu_desc_handle/font_srv_gpu_desc_handle. 29 | // font_srv_cpu_desc_handle and font_srv_gpu_desc_handle are handles to a single SRV descriptor to use for the internal font texture. 30 | IMGUI_IMPL_API bool ImGui_ImplDX12_Init(ID3D12Device* device, int num_frames_in_flight, DXGI_FORMAT rtv_format, ID3D12DescriptorHeap* cbv_srv_heap, 31 | D3D12_CPU_DESCRIPTOR_HANDLE font_srv_cpu_desc_handle, D3D12_GPU_DESCRIPTOR_HANDLE font_srv_gpu_desc_handle); 32 | IMGUI_IMPL_API void ImGui_ImplDX12_Shutdown(); 33 | IMGUI_IMPL_API void ImGui_ImplDX12_NewFrame(); 34 | IMGUI_IMPL_API void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data, ID3D12GraphicsCommandList* graphics_command_list); 35 | 36 | // Use if you want to reset your rendering device without losing Dear ImGui state. 37 | IMGUI_IMPL_API void ImGui_ImplDX12_InvalidateDeviceObjects(); 38 | IMGUI_IMPL_API bool ImGui_ImplDX12_CreateDeviceObjects(); 39 | -------------------------------------------------------------------------------- /Demo/imgui/backends/imgui_impl_dx9.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Renderer Backend for DirectX9 2 | // This needs to be used along with a Platform Backend (e.g. Win32) 3 | 4 | // Implemented features: 5 | // [X] Renderer: User texture binding. Use 'LPDIRECT3DTEXTURE9' as ImTextureID. Read the FAQ about ImTextureID! 6 | // [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices. 7 | 8 | // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. 9 | // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. 10 | // If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. 11 | // Read online: https://github.com/ocornut/imgui/tree/master/docs 12 | 13 | #pragma once 14 | #include "imgui.h" // IMGUI_IMPL_API 15 | 16 | struct IDirect3DDevice9; 17 | 18 | IMGUI_IMPL_API bool ImGui_ImplDX9_Init(IDirect3DDevice9* device); 19 | IMGUI_IMPL_API void ImGui_ImplDX9_Shutdown(); 20 | IMGUI_IMPL_API void ImGui_ImplDX9_NewFrame(); 21 | IMGUI_IMPL_API void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data); 22 | 23 | // Use if you want to reset your rendering device without losing Dear ImGui state. 24 | IMGUI_IMPL_API bool ImGui_ImplDX9_CreateDeviceObjects(); 25 | IMGUI_IMPL_API void ImGui_ImplDX9_InvalidateDeviceObjects(); 26 | -------------------------------------------------------------------------------- /Demo/imgui/backends/imgui_impl_opengl2.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Renderer Backend for OpenGL2 (legacy OpenGL, fixed pipeline) 2 | // This needs to be used along with a Platform Backend (e.g. GLFW, SDL, Win32, custom..) 3 | 4 | // Implemented features: 5 | // [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID! 6 | 7 | // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. 8 | // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. 9 | // If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. 10 | // Read online: https://github.com/ocornut/imgui/tree/master/docs 11 | 12 | // **DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)** 13 | // **Prefer using the code in imgui_impl_opengl3.cpp** 14 | // This code is mostly provided as a reference to learn how ImGui integration works, because it is shorter to read. 15 | // If your code is using GL3+ context or any semi modern OpenGL calls, using this is likely to make everything more 16 | // complicated, will require your code to reset every single OpenGL attributes to their initial state, and might 17 | // confuse your GPU driver. 18 | // The GL2 code is unable to reset attributes or even call e.g. "glUseProgram(0)" because they don't exist in that API. 19 | 20 | #pragma once 21 | #include "imgui.h" // IMGUI_IMPL_API 22 | 23 | IMGUI_IMPL_API bool ImGui_ImplOpenGL2_Init(); 24 | IMGUI_IMPL_API void ImGui_ImplOpenGL2_Shutdown(); 25 | IMGUI_IMPL_API void ImGui_ImplOpenGL2_NewFrame(); 26 | IMGUI_IMPL_API void ImGui_ImplOpenGL2_RenderDrawData(ImDrawData* draw_data); 27 | 28 | // Called by Init/NewFrame/Shutdown 29 | IMGUI_IMPL_API bool ImGui_ImplOpenGL2_CreateFontsTexture(); 30 | IMGUI_IMPL_API void ImGui_ImplOpenGL2_DestroyFontsTexture(); 31 | IMGUI_IMPL_API bool ImGui_ImplOpenGL2_CreateDeviceObjects(); 32 | IMGUI_IMPL_API void ImGui_ImplOpenGL2_DestroyDeviceObjects(); 33 | -------------------------------------------------------------------------------- /Demo/imgui/backends/imgui_impl_osx.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Platform Backend for OSX / Cocoa 2 | // This needs to be used along with a Renderer (e.g. OpenGL2, OpenGL3, Vulkan, Metal..) 3 | // - Not well tested. If you want a portable application, prefer using the GLFW or SDL platform Backends on Mac. 4 | // - Requires linking with the GameController framework ("-framework GameController"). 5 | 6 | // Implemented features: 7 | // [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. 8 | // [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy kVK_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set] 9 | // [X] Platform: OSX clipboard is supported within core Dear ImGui (no specific code in this backend). 10 | // [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. 11 | // [X] Platform: IME support. 12 | 13 | // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. 14 | // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. 15 | // If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. 16 | // Read online: https://github.com/ocornut/imgui/tree/master/docs 17 | 18 | #include "imgui.h" // IMGUI_IMPL_API 19 | 20 | #ifdef __OBJC__ 21 | 22 | @class NSEvent; 23 | @class NSView; 24 | 25 | IMGUI_IMPL_API bool ImGui_ImplOSX_Init(NSView* _Nonnull view); 26 | IMGUI_IMPL_API void ImGui_ImplOSX_Shutdown(); 27 | IMGUI_IMPL_API void ImGui_ImplOSX_NewFrame(NSView* _Nullable view); 28 | 29 | #endif 30 | 31 | //----------------------------------------------------------------------------- 32 | // C++ API 33 | //----------------------------------------------------------------------------- 34 | 35 | #ifdef IMGUI_IMPL_METAL_CPP_EXTENSIONS 36 | // #include 37 | #ifndef __OBJC__ 38 | 39 | IMGUI_IMPL_API bool ImGui_ImplOSX_Init(void* _Nonnull view); 40 | IMGUI_IMPL_API void ImGui_ImplOSX_Shutdown(); 41 | IMGUI_IMPL_API void ImGui_ImplOSX_NewFrame(void* _Nullable view); 42 | 43 | #endif 44 | #endif 45 | -------------------------------------------------------------------------------- /Demo/imgui/backends/imgui_impl_sdl2.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Platform Backend for SDL2 2 | // This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..) 3 | // (Info: SDL2 is a cross-platform general purpose library for handling windows, inputs, graphics context creation, etc.) 4 | 5 | // Implemented features: 6 | // [X] Platform: Clipboard support. 7 | // [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy SDL_SCANCODE_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set] 8 | // [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. 9 | // [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. 10 | // [X] Platform: Basic IME support. App needs to call 'SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");' before SDL_CreateWindow()!. 11 | 12 | // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. 13 | // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. 14 | // If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. 15 | // Read online: https://github.com/ocornut/imgui/tree/master/docs 16 | 17 | #pragma once 18 | #include "imgui.h" // IMGUI_IMPL_API 19 | 20 | struct SDL_Window; 21 | struct SDL_Renderer; 22 | typedef union SDL_Event SDL_Event; 23 | 24 | IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForOpenGL(SDL_Window* window, void* sdl_gl_context); 25 | IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window); 26 | IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForD3D(SDL_Window* window); 27 | IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForMetal(SDL_Window* window); 28 | IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForSDLRenderer(SDL_Window* window, SDL_Renderer* renderer); 29 | IMGUI_IMPL_API void ImGui_ImplSDL2_Shutdown(); 30 | IMGUI_IMPL_API void ImGui_ImplSDL2_NewFrame(); 31 | IMGUI_IMPL_API bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event); 32 | 33 | #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS 34 | static inline void ImGui_ImplSDL2_NewFrame(SDL_Window*) { ImGui_ImplSDL2_NewFrame(); } // 1.84: removed unnecessary parameter 35 | #endif 36 | -------------------------------------------------------------------------------- /Demo/imgui/backends/imgui_impl_sdl3.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Platform Backend for SDL3 (*EXPERIMENTAL*) 2 | // This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..) 3 | // (Info: SDL3 is a cross-platform general purpose library for handling windows, inputs, graphics context creation, etc.) 4 | // (IMPORTANT: SDL 3.0.0 is NOT YET RELEASED. IT IS POSSIBLE THAT ITS SPECS/API WILL CHANGE BEFORE RELEASE) 5 | 6 | // Implemented features: 7 | // [X] Platform: Clipboard support. 8 | // [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy SDL_SCANCODE_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set] 9 | // [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. 10 | // [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. 11 | // Missing features: 12 | // [x] Platform: Basic IME support. Position somehow broken in SDL3 + app needs to call 'SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");' before SDL_CreateWindow()!. 13 | 14 | // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. 15 | // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. 16 | // If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. 17 | // Read online: https://github.com/ocornut/imgui/tree/master/docs 18 | 19 | #pragma once 20 | #include "imgui.h" // IMGUI_IMPL_API 21 | 22 | struct SDL_Window; 23 | struct SDL_Renderer; 24 | typedef union SDL_Event SDL_Event; 25 | 26 | IMGUI_IMPL_API bool ImGui_ImplSDL3_InitForOpenGL(SDL_Window* window, void* sdl_gl_context); 27 | IMGUI_IMPL_API bool ImGui_ImplSDL3_InitForVulkan(SDL_Window* window); 28 | IMGUI_IMPL_API bool ImGui_ImplSDL3_InitForD3D(SDL_Window* window); 29 | IMGUI_IMPL_API bool ImGui_ImplSDL3_InitForMetal(SDL_Window* window); 30 | IMGUI_IMPL_API bool ImGui_ImplSDL3_InitForSDLRenderer(SDL_Window* window, SDL_Renderer* renderer); 31 | IMGUI_IMPL_API void ImGui_ImplSDL3_Shutdown(); 32 | IMGUI_IMPL_API void ImGui_ImplSDL3_NewFrame(); 33 | IMGUI_IMPL_API bool ImGui_ImplSDL3_ProcessEvent(const SDL_Event* event); 34 | -------------------------------------------------------------------------------- /Demo/imgui/backends/imgui_impl_sdlrenderer.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Renderer Backend for SDL_Renderer 2 | // (Requires: SDL 2.0.17+) 3 | 4 | // Important to understand: SDL_Renderer is an _optional_ component of SDL. 5 | // For a multi-platform app consider using e.g. SDL+DirectX on Windows and SDL+OpenGL on Linux/OSX. 6 | // If your application will want to render any non trivial amount of graphics other than UI, 7 | // please be aware that SDL_Renderer offers a limited graphic API to the end-user and it might 8 | // be difficult to step out of those boundaries. 9 | // However, we understand it is a convenient choice to get an app started easily. 10 | 11 | // Implemented features: 12 | // [X] Renderer: User texture binding. Use 'SDL_Texture*' as ImTextureID. Read the FAQ about ImTextureID! 13 | // [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices. 14 | 15 | #pragma once 16 | #include "imgui.h" // IMGUI_IMPL_API 17 | 18 | struct SDL_Renderer; 19 | 20 | IMGUI_IMPL_API bool ImGui_ImplSDLRenderer_Init(SDL_Renderer* renderer); 21 | IMGUI_IMPL_API void ImGui_ImplSDLRenderer_Shutdown(); 22 | IMGUI_IMPL_API void ImGui_ImplSDLRenderer_NewFrame(); 23 | IMGUI_IMPL_API void ImGui_ImplSDLRenderer_RenderDrawData(ImDrawData* draw_data); 24 | 25 | // Called by Init/NewFrame/Shutdown 26 | IMGUI_IMPL_API bool ImGui_ImplSDLRenderer_CreateFontsTexture(); 27 | IMGUI_IMPL_API void ImGui_ImplSDLRenderer_DestroyFontsTexture(); 28 | IMGUI_IMPL_API bool ImGui_ImplSDLRenderer_CreateDeviceObjects(); 29 | IMGUI_IMPL_API void ImGui_ImplSDLRenderer_DestroyDeviceObjects(); 30 | -------------------------------------------------------------------------------- /Demo/imgui/backends/imgui_impl_wgpu.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Renderer for WebGPU 2 | // This needs to be used along with a Platform Binding (e.g. GLFW) 3 | // (Please note that WebGPU is currently experimental, will not run on non-beta browsers, and may break.) 4 | 5 | // Implemented features: 6 | // [X] Renderer: User texture binding. Use 'WGPUTextureView' as ImTextureID. Read the FAQ about ImTextureID! 7 | // [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices. 8 | 9 | // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. 10 | // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. 11 | // If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. 12 | // Read online: https://github.com/ocornut/imgui/tree/master/docs 13 | 14 | #pragma once 15 | #include "imgui.h" // IMGUI_IMPL_API 16 | #include 17 | 18 | IMGUI_IMPL_API bool ImGui_ImplWGPU_Init(WGPUDevice device, int num_frames_in_flight, WGPUTextureFormat rt_format, WGPUTextureFormat depth_format = WGPUTextureFormat_Undefined); 19 | IMGUI_IMPL_API void ImGui_ImplWGPU_Shutdown(); 20 | IMGUI_IMPL_API void ImGui_ImplWGPU_NewFrame(); 21 | IMGUI_IMPL_API void ImGui_ImplWGPU_RenderDrawData(ImDrawData* draw_data, WGPURenderPassEncoder pass_encoder); 22 | 23 | // Use if you want to reset your rendering device without losing Dear ImGui state. 24 | IMGUI_IMPL_API void ImGui_ImplWGPU_InvalidateDeviceObjects(); 25 | IMGUI_IMPL_API bool ImGui_ImplWGPU_CreateDeviceObjects(); 26 | -------------------------------------------------------------------------------- /Demo/imgui/backends/vulkan/generate_spv.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ## -V: create SPIR-V binary 3 | ## -x: save binary output as text-based 32-bit hexadecimal numbers 4 | ## -o: output file 5 | glslangValidator -V -x -o glsl_shader.frag.u32 glsl_shader.frag 6 | glslangValidator -V -x -o glsl_shader.vert.u32 glsl_shader.vert 7 | -------------------------------------------------------------------------------- /Demo/imgui/backends/vulkan/glsl_shader.frag: -------------------------------------------------------------------------------- 1 | #version 450 core 2 | layout(location = 0) out vec4 fColor; 3 | 4 | layout(set=0, binding=0) uniform sampler2D sTexture; 5 | 6 | layout(location = 0) in struct { 7 | vec4 Color; 8 | vec2 UV; 9 | } In; 10 | 11 | void main() 12 | { 13 | fColor = In.Color * texture(sTexture, In.UV.st); 14 | } 15 | -------------------------------------------------------------------------------- /Demo/imgui/backends/vulkan/glsl_shader.vert: -------------------------------------------------------------------------------- 1 | #version 450 core 2 | layout(location = 0) in vec2 aPos; 3 | layout(location = 1) in vec2 aUV; 4 | layout(location = 2) in vec4 aColor; 5 | 6 | layout(push_constant) uniform uPushConstant { 7 | vec2 uScale; 8 | vec2 uTranslate; 9 | } pc; 10 | 11 | out gl_PerVertex { 12 | vec4 gl_Position; 13 | }; 14 | 15 | layout(location = 0) out struct { 16 | vec4 Color; 17 | vec2 UV; 18 | } Out; 19 | 20 | void main() 21 | { 22 | Out.Color = aColor; 23 | Out.UV = aUV; 24 | gl_Position = vec4(aPos * pc.uScale + pc.uTranslate, 0, 1); 25 | } 26 | -------------------------------------------------------------------------------- /Demo/imgui/examples/README.txt: -------------------------------------------------------------------------------- 1 | See BACKENDS and EXAMPLES files in the docs/ folder, or on the web at: https://github.com/ocornut/imgui/tree/master/docs 2 | 3 | Backends = Helper code to facilitate integration with platforms/graphics api (used by Examples + should be used by your app). 4 | Examples = Standalone applications showcasing integration with platforms/graphics api. 5 | 6 | Some Examples have extra README files in their respective directory, please check them too! 7 | 8 | Once Dear ImGui is running (in either examples or your own application/game/engine), 9 | run and refer to ImGui::ShowDemoWindow() in imgui_demo.cpp for the end-user API. 10 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_allegro5/README.md: -------------------------------------------------------------------------------- 1 | 2 | # Configuration 3 | 4 | Dear ImGui outputs 16-bit vertex indices by default. 5 | Allegro doesn't support them natively, so we have two solutions: convert the indices manually in imgui_impl_allegro5.cpp, or compile dear imgui with 32-bit indices. 6 | You can either modify imconfig.h that comes with Dear ImGui (easier), or set a C++ preprocessor option IMGUI_USER_CONFIG to find to a filename. 7 | We are providing `imconfig_allegro5.h` that enables 32-bit indices. 8 | Note that the backend supports _BOTH_ 16-bit and 32-bit indices, but 32-bit indices will be slightly faster as they won't require a manual conversion. 9 | 10 | # How to Build 11 | 12 | ### On Ubuntu 14.04+ and macOS 13 | 14 | ```bash 15 | g++ -DIMGUI_USER_CONFIG=\"examples/example_allegro5/imconfig_allegro5.h\" -I .. -I ../.. -I ../../backends main.cpp ../../backends/imgui_impl_allegro5.cpp ../../imgui*.cpp -lallegro -lallegro_main -lallegro_primitives -o allegro5_example 16 | ``` 17 | 18 | On macOS, install Allegro with homebrew: `brew install allegro`. 19 | 20 | ### On Windows with Visual Studio's CLI 21 | 22 | You may install Allegro using vcpkg: 23 | ``` 24 | git clone https://github.com/Microsoft/vcpkg 25 | cd vcpkg 26 | bootstrap-vcpkg.bat 27 | vcpkg install allegro5 --triplet=x86-windows ; for win32 28 | vcpkg install allegro5 --triplet=x64-windows ; for win64 29 | vcpkg integrate install ; register include / libs in Visual Studio 30 | ``` 31 | 32 | Build: 33 | ``` 34 | set ALLEGRODIR=path_to_your_allegro5_folder 35 | cl /Zi /MD /I %ALLEGRODIR%\include /DIMGUI_USER_CONFIG=\"examples/example_allegro5/imconfig_allegro5.h\" /I .. /I ..\.. /I ..\..\backends main.cpp ..\..\backends\imgui_impl_allegro5.cpp ..\..\imgui*.cpp /link /LIBPATH:%ALLEGRODIR%\lib allegro-5.0.10-monolith-md.lib user32.lib 36 | ``` 37 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_allegro5/example_allegro5.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {20b90ce4-7fcb-4731-b9a0-075f875de82d} 6 | 7 | 8 | {f18ab499-84e1-499f-8eff-9754361e0e52} 9 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 10 | 11 | 12 | 13 | 14 | imgui 15 | 16 | 17 | imgui 18 | 19 | 20 | imgui 21 | 22 | 23 | sources 24 | 25 | 26 | sources 27 | 28 | 29 | sources 30 | 31 | 32 | imgui 33 | 34 | 35 | imgui 36 | 37 | 38 | 39 | 40 | imgui 41 | 42 | 43 | imgui 44 | 45 | 46 | imgui 47 | 48 | 49 | sources 50 | 51 | 52 | 53 | 54 | 55 | imgui 56 | 57 | 58 | imgui 59 | 60 | 61 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_allegro5/imconfig_allegro5.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // COMPILE-TIME OPTIONS FOR DEAR IMGUI ALLEGRO 5 EXAMPLE 3 | // See imconfig.h for the full template 4 | // Because Allegro doesn't support 16-bit vertex indices, we enable the compile-time option of imgui to use 32-bit indices 5 | //----------------------------------------------------------------------------- 6 | 7 | #pragma once 8 | 9 | // Use 32-bit vertex indices because Allegro doesn't support 16-bit ones 10 | // This allows us to avoid converting vertices format at runtime 11 | #define ImDrawIdx int 12 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_android_opengl3/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.6) 2 | 3 | project(ImGuiExample) 4 | 5 | set(CMAKE_CXX_STANDARD 11) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | set(CMAKE_CXX_EXTENSIONS OFF) 8 | 9 | add_library(${CMAKE_PROJECT_NAME} SHARED 10 | ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp 11 | ${CMAKE_CURRENT_SOURCE_DIR}/../../imgui.cpp 12 | ${CMAKE_CURRENT_SOURCE_DIR}/../../imgui_demo.cpp 13 | ${CMAKE_CURRENT_SOURCE_DIR}/../../imgui_draw.cpp 14 | ${CMAKE_CURRENT_SOURCE_DIR}/../../imgui_tables.cpp 15 | ${CMAKE_CURRENT_SOURCE_DIR}/../../imgui_widgets.cpp 16 | ${CMAKE_CURRENT_SOURCE_DIR}/../../backends/imgui_impl_android.cpp 17 | ${CMAKE_CURRENT_SOURCE_DIR}/../../backends/imgui_impl_opengl3.cpp 18 | ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c 19 | ) 20 | 21 | set(CMAKE_SHARED_LINKER_FLAGS 22 | "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate" 23 | ) 24 | 25 | target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE 26 | IMGUI_IMPL_OPENGL_ES3 27 | ) 28 | 29 | target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE 30 | ${CMAKE_CURRENT_SOURCE_DIR}/../.. 31 | ${CMAKE_CURRENT_SOURCE_DIR}/../../backends 32 | ${ANDROID_NDK}/sources/android/native_app_glue 33 | ) 34 | 35 | target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE 36 | android 37 | EGL 38 | GLESv3 39 | log 40 | ) 41 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_android_opengl3/android/.gitignore: -------------------------------------------------------------------------------- 1 | .cxx 2 | .externalNativeBuild 3 | build/ 4 | *.iml 5 | 6 | .idea 7 | .gradle 8 | local.properties 9 | 10 | # Android Studio puts a Gradle wrapper here, that we don't want: 11 | gradle/ 12 | gradlew* 13 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_android_opengl3/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'kotlin-android' 3 | 4 | android { 5 | compileSdkVersion 33 6 | buildToolsVersion "33.0.2" 7 | ndkVersion "25.2.9519653" 8 | 9 | defaultConfig { 10 | applicationId "imgui.example.android" 11 | namespace "imgui.example.android" 12 | minSdkVersion 24 13 | targetSdkVersion 33 14 | versionCode 1 15 | versionName "1.0" 16 | } 17 | 18 | buildTypes { 19 | release { 20 | minifyEnabled false 21 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt') 22 | } 23 | } 24 | 25 | compileOptions { 26 | sourceCompatibility JavaVersion.VERSION_11 27 | targetCompatibility JavaVersion.VERSION_11 28 | } 29 | 30 | kotlinOptions { 31 | jvmTarget="11" 32 | } 33 | 34 | externalNativeBuild { 35 | cmake { 36 | path "../../CMakeLists.txt" 37 | version '3.22.1' 38 | } 39 | } 40 | } 41 | repositories { 42 | mavenCentral() 43 | } 44 | dependencies { 45 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 46 | } 47 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_android_opengl3/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 15 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_android_opengl3/android/app/src/main/java/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package imgui.example.android 2 | 3 | import android.app.NativeActivity 4 | import android.os.Bundle 5 | import android.content.Context 6 | import android.view.inputmethod.InputMethodManager 7 | import android.view.KeyEvent 8 | import java.util.concurrent.LinkedBlockingQueue 9 | 10 | class MainActivity : NativeActivity() { 11 | public override fun onCreate(savedInstanceState: Bundle?) { 12 | super.onCreate(savedInstanceState) 13 | } 14 | 15 | fun showSoftInput() { 16 | val inputMethodManager = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager 17 | inputMethodManager.showSoftInput(this.window.decorView, 0) 18 | } 19 | 20 | fun hideSoftInput() { 21 | val inputMethodManager = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager 22 | inputMethodManager.hideSoftInputFromWindow(this.window.decorView.windowToken, 0) 23 | } 24 | 25 | // Queue for the Unicode characters to be polled from native code (via pollUnicodeChar()) 26 | private var unicodeCharacterQueue: LinkedBlockingQueue = LinkedBlockingQueue() 27 | 28 | // We assume dispatchKeyEvent() of the NativeActivity is actually called for every 29 | // KeyEvent and not consumed by any View before it reaches here 30 | override fun dispatchKeyEvent(event: KeyEvent): Boolean { 31 | if (event.action == KeyEvent.ACTION_DOWN) { 32 | unicodeCharacterQueue.offer(event.getUnicodeChar(event.metaState)) 33 | } 34 | return super.dispatchKeyEvent(event) 35 | } 36 | 37 | fun pollUnicodeChar(): Int { 38 | return unicodeCharacterQueue.poll() ?: 0 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_android_opengl3/android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.8.0' 3 | repositories { 4 | google() 5 | mavenCentral() 6 | 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:7.4.1' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | google() 18 | mavenCentral() 19 | } 20 | } 21 | 22 | task clean(type: Delete) { 23 | delete rootProject.buildDir 24 | } 25 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_android_opengl3/android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_apple_metal/README.md: -------------------------------------------------------------------------------- 1 | # iOS / OSX Metal example 2 | 3 | ## Introduction 4 | 5 | This example shows how to integrate Dear ImGui with Metal. It is based on the "cross-platform" game template provided with Xcode as of Xcode 9. 6 | 7 | Consider basing your work off the example_glfw_metal/ or example_sdl2_metal/ examples. They are better supported and will be portable unlike this one. 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_apple_metal/iOS/Info-iOS.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | imgui 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIRequiredDeviceCapabilities 26 | 27 | armv7 28 | metal 29 | 30 | UIRequiresFullScreen 31 | 32 | UIStatusBarHidden 33 | 34 | UISupportedInterfaceOrientations 35 | 36 | UIInterfaceOrientationPortrait 37 | UIInterfaceOrientationLandscapeLeft 38 | UIInterfaceOrientationLandscapeRight 39 | UIInterfaceOrientationPortraitUpsideDown 40 | 41 | UISupportedInterfaceOrientations~ipad 42 | 43 | UIInterfaceOrientationPortrait 44 | UIInterfaceOrientationPortraitUpsideDown 45 | UIInterfaceOrientationLandscapeLeft 46 | UIInterfaceOrientationLandscapeRight 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_apple_metal/iOS/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_apple_metal/macOS/Info-macOS.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | imgui 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleVersion 22 | 1 23 | LSMinimumSystemVersion 24 | $(MACOSX_DEPLOYMENT_TARGET) 25 | NSMainStoryboardFile 26 | MainMenu 27 | NSPrincipalClass 28 | NSApplication 29 | 30 | 31 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_emscripten_wgpu/README.md: -------------------------------------------------------------------------------- 1 | ## How to Build 2 | 3 | - You need to install Emscripten from https://emscripten.org/docs/getting_started/downloads.html, and have the environment variables set, as described in https://emscripten.org/docs/getting_started/downloads.html#installation-instructions 4 | 5 | - Depending on your configuration, in Windows you may need to run `emsdk/emsdk_env.bat` in your console to access the Emscripten command-line tools. 6 | 7 | - You may also refer to our [Continuous Integration setup](https://github.com/ocornut/imgui/tree/master/.github/workflows) for Emscripten setup. 8 | 9 | - Then build using `make` while in the `example_emscripten_wgpu/` directory. 10 | 11 | - Requires recent Emscripten as WGPU is still a work-in-progress API. 12 | 13 | ## How to Run 14 | 15 | To run on a local machine: 16 | - Make sure your browse supports WGPU and it is enabled. WGPU is still WIP not enabled by default in most browser. 17 | - `make serve` will use Python3 to spawn a local webserver, you can then browse http://localhost:8000 to access your build. 18 | - Otherwise, generally you will need a local webserver: 19 | - Quoting [https://emscripten.org/docs/getting_started](https://emscripten.org/docs/getting_started/Tutorial.html#generating-html):
20 | _"Unfortunately several browsers (including Chrome, Safari, and Internet Explorer) do not support file:// [XHR](https://emscripten.org/docs/site/glossary.html#term-xhr) requests, and can’t load extra files needed by the HTML (like a .wasm file, or packaged file data as mentioned lower down). For these browsers you’ll need to serve the files using a [local webserver](https://emscripten.org/docs/getting_started/FAQ.html#faq-local-webserver) and then open http://localhost:8000/hello.html."_ 21 | - Emscripten SDK has a handy `emrun` command: `emrun web/example_emscripten_opengl3.html --browser firefox` which will spawn a temporary local webserver (in Firefox). See https://emscripten.org/docs/compiling/Running-html-files-with-emrun.html for details. 22 | - You may use Python 3 builtin webserver: `python -m http.server -d web` (this is what `make serve` uses). 23 | - You may use Python 2 builtin webserver: `cd web && python -m SimpleHTTPServer`. 24 | - If you are accessing the files over a network, certain browsers, such as Firefox, will restrict Gamepad API access to secure contexts only (e.g. https only). 25 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_glfw_metal/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # You will need GLFW (http://www.glfw.org): 3 | # brew install glfw 4 | # 5 | 6 | #CXX = g++ 7 | #CXX = clang++ 8 | 9 | EXE = example_glfw_metal 10 | IMGUI_DIR = ../.. 11 | SOURCES = main.mm 12 | SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_tables.cpp $(IMGUI_DIR)/imgui_widgets.cpp 13 | SOURCES += $(IMGUI_DIR)/backends/imgui_impl_glfw.cpp $(IMGUI_DIR)/backends/imgui_impl_metal.mm 14 | OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES)))) 15 | 16 | LIBS = -framework Metal -framework MetalKit -framework Cocoa -framework IOKit -framework CoreVideo -framework QuartzCore 17 | LIBS += -L/usr/local/lib -L/opt/homebrew/lib 18 | LIBS += -lglfw 19 | 20 | CXXFLAGS = -std=c++11 -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends -I/usr/local/include -I/opt/homebrew/include 21 | CXXFLAGS += -Wall -Wformat 22 | CFLAGS = $(CXXFLAGS) 23 | 24 | %.o:%.cpp 25 | $(CXX) $(CXXFLAGS) -c -o $@ $< 26 | 27 | %.o:$(IMGUI_DIR)/%.cpp 28 | $(CXX) $(CXXFLAGS) -c -o $@ $< 29 | 30 | %.o:$(IMGUI_DIR)/backends/%.cpp 31 | $(CXX) $(CXXFLAGS) -c -o $@ $< 32 | 33 | %.o:%.mm 34 | $(CXX) $(CXXFLAGS) -ObjC++ -fobjc-weak -fobjc-arc -c -o $@ $< 35 | 36 | %.o:$(IMGUI_DIR)/backends/%.mm 37 | $(CXX) $(CXXFLAGS) -ObjC++ -fobjc-weak -fobjc-arc -c -o $@ $< 38 | 39 | all: $(EXE) 40 | @echo Build complete 41 | 42 | $(EXE): $(OBJS) 43 | $(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS) 44 | 45 | clean: 46 | rm -f $(EXE) $(OBJS) 47 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_glfw_opengl2/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Cross Platform Makefile 3 | # Compatible with MSYS2/MINGW, Ubuntu 14.04.1 and Mac OS X 4 | # 5 | # You will need GLFW (http://www.glfw.org): 6 | # Linux: 7 | # apt-get install libglfw-dev 8 | # Mac OS X: 9 | # brew install glfw 10 | # MSYS2: 11 | # pacman -S --noconfirm --needed mingw-w64-x86_64-toolchain mingw-w64-x86_64-glfw 12 | # 13 | 14 | #CXX = g++ 15 | #CXX = clang++ 16 | 17 | EXE = example_glfw_opengl2 18 | IMGUI_DIR = ../.. 19 | SOURCES = main.cpp 20 | SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_tables.cpp $(IMGUI_DIR)/imgui_widgets.cpp 21 | SOURCES += $(IMGUI_DIR)/backends/imgui_impl_glfw.cpp $(IMGUI_DIR)/backends/imgui_impl_opengl2.cpp 22 | OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES)))) 23 | UNAME_S := $(shell uname -s) 24 | 25 | CXXFLAGS = -std=c++11 -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends 26 | CXXFLAGS += -g -Wall -Wformat 27 | LIBS = 28 | 29 | ##--------------------------------------------------------------------- 30 | ## BUILD FLAGS PER PLATFORM 31 | ##--------------------------------------------------------------------- 32 | 33 | ifeq ($(UNAME_S), Linux) #LINUX 34 | ECHO_MESSAGE = "Linux" 35 | LIBS += -lGL `pkg-config --static --libs glfw3` 36 | 37 | CXXFLAGS += `pkg-config --cflags glfw3` 38 | CFLAGS = $(CXXFLAGS) 39 | endif 40 | 41 | ifeq ($(UNAME_S), Darwin) #APPLE 42 | ECHO_MESSAGE = "Mac OS X" 43 | LIBS += -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo 44 | LIBS += -L/usr/local/lib -L/opt/local/lib -L/opt/homebrew/lib 45 | #LIBS += -lglfw3 46 | LIBS += -lglfw 47 | 48 | CXXFLAGS += -I/usr/local/include -I/opt/local/include -I/opt/homebrew/include 49 | CFLAGS = $(CXXFLAGS) 50 | endif 51 | 52 | ifeq ($(OS), Windows_NT) 53 | ECHO_MESSAGE = "MinGW" 54 | LIBS += -lglfw3 -lgdi32 -lopengl32 -limm32 55 | 56 | CXXFLAGS += `pkg-config --cflags glfw3` 57 | CFLAGS = $(CXXFLAGS) 58 | endif 59 | 60 | ##--------------------------------------------------------------------- 61 | ## BUILD RULES 62 | ##--------------------------------------------------------------------- 63 | 64 | %.o:%.cpp 65 | $(CXX) $(CXXFLAGS) -c -o $@ $< 66 | 67 | %.o:$(IMGUI_DIR)/%.cpp 68 | $(CXX) $(CXXFLAGS) -c -o $@ $< 69 | 70 | %.o:$(IMGUI_DIR)/backends/%.cpp 71 | $(CXX) $(CXXFLAGS) -c -o $@ $< 72 | 73 | all: $(EXE) 74 | @echo Build complete for $(ECHO_MESSAGE) 75 | 76 | $(EXE): $(OBJS) 77 | $(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS) 78 | 79 | clean: 80 | rm -f $(EXE) $(OBJS) 81 | 82 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_glfw_opengl2/build_win32.bat: -------------------------------------------------------------------------------- 1 | @REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler. 2 | @set OUT_DIR=Debug 3 | @set OUT_EXE=example_glfw_opengl2 4 | @set INCLUDES=/I..\.. /I..\..\backends /I..\libs\glfw\include 5 | @set SOURCES=main.cpp ..\..\backends\imgui_impl_opengl2.cpp ..\..\backends\imgui_impl_glfw.cpp ..\..\imgui*.cpp 6 | @set LIBS=/LIBPATH:..\libs\glfw\lib-vc2010-32 glfw3.lib opengl32.lib gdi32.lib shell32.lib 7 | mkdir %OUT_DIR% 8 | cl /nologo /Zi /MD %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% 9 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_glfw_opengl2/example_glfw_opengl2.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {c336cfe3-f0c4-464c-9ef0-a9e17a7ff222} 6 | 7 | 8 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 9 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 10 | 11 | 12 | 13 | 14 | sources 15 | 16 | 17 | imgui 18 | 19 | 20 | imgui 21 | 22 | 23 | imgui 24 | 25 | 26 | imgui 27 | 28 | 29 | imgui 30 | 31 | 32 | sources 33 | 34 | 35 | sources 36 | 37 | 38 | 39 | 40 | imgui 41 | 42 | 43 | imgui 44 | 45 | 46 | imgui 47 | 48 | 49 | sources 50 | 51 | 52 | sources 53 | 54 | 55 | 56 | 57 | 58 | imgui 59 | 60 | 61 | imgui 62 | 63 | 64 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_glfw_opengl3/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Cross Platform Makefile 3 | # Compatible with MSYS2/MINGW, Ubuntu 14.04.1 and Mac OS X 4 | # 5 | # You will need GLFW (http://www.glfw.org): 6 | # Linux: 7 | # apt-get install libglfw-dev 8 | # Mac OS X: 9 | # brew install glfw 10 | # MSYS2: 11 | # pacman -S --noconfirm --needed mingw-w64-x86_64-toolchain mingw-w64-x86_64-glfw 12 | # 13 | 14 | #CXX = g++ 15 | #CXX = clang++ 16 | 17 | EXE = example_glfw_opengl3 18 | IMGUI_DIR = ../.. 19 | SOURCES = main.cpp 20 | SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_tables.cpp $(IMGUI_DIR)/imgui_widgets.cpp 21 | SOURCES += $(IMGUI_DIR)/backends/imgui_impl_glfw.cpp $(IMGUI_DIR)/backends/imgui_impl_opengl3.cpp 22 | OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES)))) 23 | UNAME_S := $(shell uname -s) 24 | LINUX_GL_LIBS = -lGL 25 | 26 | CXXFLAGS = -std=c++11 -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends 27 | CXXFLAGS += -g -Wall -Wformat 28 | LIBS = 29 | 30 | ##--------------------------------------------------------------------- 31 | ## OPENGL ES 32 | ##--------------------------------------------------------------------- 33 | 34 | ## This assumes a GL ES library available in the system, e.g. libGLESv2.so 35 | # CXXFLAGS += -DIMGUI_IMPL_OPENGL_ES2 36 | # LINUX_GL_LIBS = -lGLESv2 37 | 38 | ##--------------------------------------------------------------------- 39 | ## BUILD FLAGS PER PLATFORM 40 | ##--------------------------------------------------------------------- 41 | 42 | ifeq ($(UNAME_S), Linux) #LINUX 43 | ECHO_MESSAGE = "Linux" 44 | LIBS += $(LINUX_GL_LIBS) `pkg-config --static --libs glfw3` 45 | 46 | CXXFLAGS += `pkg-config --cflags glfw3` 47 | CFLAGS = $(CXXFLAGS) 48 | endif 49 | 50 | ifeq ($(UNAME_S), Darwin) #APPLE 51 | ECHO_MESSAGE = "Mac OS X" 52 | LIBS += -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo 53 | LIBS += -L/usr/local/lib -L/opt/local/lib -L/opt/homebrew/lib 54 | #LIBS += -lglfw3 55 | LIBS += -lglfw 56 | 57 | CXXFLAGS += -I/usr/local/include -I/opt/local/include -I/opt/homebrew/include 58 | CFLAGS = $(CXXFLAGS) 59 | endif 60 | 61 | ifeq ($(OS), Windows_NT) 62 | ECHO_MESSAGE = "MinGW" 63 | LIBS += -lglfw3 -lgdi32 -lopengl32 -limm32 64 | 65 | CXXFLAGS += `pkg-config --cflags glfw3` 66 | CFLAGS = $(CXXFLAGS) 67 | endif 68 | 69 | ##--------------------------------------------------------------------- 70 | ## BUILD RULES 71 | ##--------------------------------------------------------------------- 72 | 73 | %.o:%.cpp 74 | $(CXX) $(CXXFLAGS) -c -o $@ $< 75 | 76 | %.o:$(IMGUI_DIR)/%.cpp 77 | $(CXX) $(CXXFLAGS) -c -o $@ $< 78 | 79 | %.o:$(IMGUI_DIR)/backends/%.cpp 80 | $(CXX) $(CXXFLAGS) -c -o $@ $< 81 | 82 | all: $(EXE) 83 | @echo Build complete for $(ECHO_MESSAGE) 84 | 85 | $(EXE): $(OBJS) 86 | $(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS) 87 | 88 | clean: 89 | rm -f $(EXE) $(OBJS) 90 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_glfw_opengl3/build_win32.bat: -------------------------------------------------------------------------------- 1 | @REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler. 2 | @set OUT_DIR=Debug 3 | @set OUT_EXE=example_glfw_opengl3 4 | @set INCLUDES=/I..\.. /I..\..\backends /I..\libs\glfw\include 5 | @set SOURCES=main.cpp ..\..\backends\imgui_impl_glfw.cpp ..\..\backends\imgui_impl_opengl3.cpp ..\..\imgui*.cpp 6 | @set LIBS=/LIBPATH:..\libs\glfw\lib-vc2010-32 glfw3.lib opengl32.lib gdi32.lib shell32.lib 7 | mkdir %OUT_DIR% 8 | cl /nologo /Zi /MD %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% 9 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_glfw_opengl3/example_glfw_opengl3.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {20b90ce4-7fcb-4731-b9a0-075f875de82d} 6 | 7 | 8 | {f18ab499-84e1-499f-8eff-9754361e0e52} 9 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 10 | 11 | 12 | 13 | 14 | sources 15 | 16 | 17 | imgui 18 | 19 | 20 | imgui 21 | 22 | 23 | imgui 24 | 25 | 26 | imgui 27 | 28 | 29 | imgui 30 | 31 | 32 | sources 33 | 34 | 35 | sources 36 | 37 | 38 | 39 | 40 | imgui 41 | 42 | 43 | imgui 44 | 45 | 46 | imgui 47 | 48 | 49 | sources 50 | 51 | 52 | sources 53 | 54 | 55 | sources 56 | 57 | 58 | 59 | 60 | 61 | imgui 62 | 63 | 64 | imgui 65 | 66 | 67 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_glfw_vulkan/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Example usage: 2 | # mkdir build 3 | # cd build 4 | # cmake -g "Visual Studio 14 2015" .. 5 | 6 | cmake_minimum_required(VERSION 2.8) 7 | project(imgui_example_glfw_vulkan C CXX) 8 | 9 | if(NOT CMAKE_BUILD_TYPE) 10 | set(CMAKE_BUILD_TYPE Debug CACHE STRING "" FORCE) 11 | endif() 12 | 13 | set(CMAKE_CXX_STANDARD 11) 14 | set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DVK_PROTOTYPES") 15 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVK_PROTOTYPES") 16 | 17 | # GLFW 18 | set(GLFW_DIR ../../../glfw) # Set this to point to an up-to-date GLFW repo 19 | option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" OFF) 20 | option(GLFW_BUILD_TESTS "Build the GLFW test programs" OFF) 21 | option(GLFW_BUILD_DOCS "Build the GLFW documentation" OFF) 22 | option(GLFW_INSTALL "Generate installation target" OFF) 23 | option(GLFW_DOCUMENT_INTERNALS "Include internals in documentation" OFF) 24 | add_subdirectory(${GLFW_DIR} binary_dir EXCLUDE_FROM_ALL) 25 | include_directories(${GLFW_DIR}/include) 26 | 27 | # Dear ImGui 28 | set(IMGUI_DIR ../../) 29 | include_directories(${IMGUI_DIR} ${IMGUI_DIR}/backends ..) 30 | 31 | # Libraries 32 | find_package(Vulkan REQUIRED) 33 | #find_library(VULKAN_LIBRARY 34 | #NAMES vulkan vulkan-1) 35 | #set(LIBRARIES "glfw;${VULKAN_LIBRARY}") 36 | set(LIBRARIES "glfw;Vulkan::Vulkan") 37 | 38 | # Use vulkan headers from glfw: 39 | include_directories(${GLFW_DIR}/deps) 40 | 41 | file(GLOB sources *.cpp) 42 | 43 | add_executable(example_glfw_vulkan ${sources} ${IMGUI_DIR}/backends/imgui_impl_glfw.cpp ${IMGUI_DIR}/backends/imgui_impl_vulkan.cpp ${IMGUI_DIR}/imgui.cpp ${IMGUI_DIR}/imgui_draw.cpp ${IMGUI_DIR}/imgui_demo.cpp ${IMGUI_DIR}/imgui_tables.cpp ${IMGUI_DIR}/imgui_widgets.cpp) 44 | target_link_libraries(example_glfw_vulkan ${LIBRARIES}) 45 | target_compile_definitions(example_glfw_vulkan PUBLIC -DImTextureID=ImU64) 46 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_glfw_vulkan/build_win32.bat: -------------------------------------------------------------------------------- 1 | @REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler. 2 | 3 | @set OUT_EXE=example_glfw_vulkan 4 | @set INCLUDES=/I..\.. /I..\..\backends /I..\libs\glfw\include /I %VULKAN_SDK%\include 5 | @set SOURCES=main.cpp ..\..\backends\imgui_impl_vulkan.cpp ..\..\backends\imgui_impl_glfw.cpp ..\..\imgui*.cpp 6 | @set LIBS=/LIBPATH:..\libs\glfw\lib-vc2010-32 /libpath:%VULKAN_SDK%\lib32 glfw3.lib opengl32.lib gdi32.lib shell32.lib vulkan-1.lib 7 | 8 | @set OUT_DIR=Debug 9 | mkdir %OUT_DIR% 10 | cl /nologo /Zi /MD %INCLUDES% /D ImTextureID=ImU64 %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% 11 | 12 | @set OUT_DIR=Release 13 | mkdir %OUT_DIR% 14 | cl /nologo /Zi /MD /Ox /Oi %INCLUDES% /D ImTextureID=ImU64 %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% 15 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_glfw_vulkan/build_win64.bat: -------------------------------------------------------------------------------- 1 | @REM Build for Visual Studio compiler. Run your copy of amd64/vcvars32.bat to setup 64-bit command-line compiler. 2 | 3 | @set INCLUDES=/I..\.. /I..\..\backends /I..\libs\glfw\include /I %VULKAN_SDK%\include 4 | @set SOURCES=main.cpp ..\..\backends\imgui_impl_vulkan.cpp ..\..\backends\imgui_impl_glfw.cpp ..\..\imgui*.cpp 5 | @set LIBS=/LIBPATH:..\libs\glfw\lib-vc2010-64 /libpath:%VULKAN_SDK%\lib glfw3.lib opengl32.lib gdi32.lib shell32.lib vulkan-1.lib 6 | 7 | @set OUT_DIR=Debug 8 | mkdir %OUT_DIR% 9 | cl /nologo /Zi /MD %INCLUDES% /D ImTextureID=ImU64 %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% 10 | 11 | @set OUT_DIR=Release 12 | mkdir %OUT_DIR% 13 | cl /nologo /Zi /MD /Ox /Oi %INCLUDES% /D ImTextureID=ImU64 %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% 14 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {20b90ce4-7fcb-4731-b9a0-075f875de82d} 6 | 7 | 8 | {f18ab499-84e1-499f-8eff-9754361e0e52} 9 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 10 | 11 | 12 | 13 | 14 | sources 15 | 16 | 17 | imgui 18 | 19 | 20 | imgui 21 | 22 | 23 | imgui 24 | 25 | 26 | imgui 27 | 28 | 29 | imgui 30 | 31 | 32 | sources 33 | 34 | 35 | sources 36 | 37 | 38 | 39 | 40 | imgui 41 | 42 | 43 | imgui 44 | 45 | 46 | imgui 47 | 48 | 49 | sources 50 | 51 | 52 | sources 53 | 54 | 55 | 56 | 57 | 58 | imgui 59 | 60 | 61 | imgui 62 | 63 | 64 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_glut_opengl2/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Cross Platform Makefile 3 | # Compatible with MSYS2/MINGW, Ubuntu 14.04.1 and Mac OS X 4 | # 5 | # Linux: 6 | # apt-get install freeglut3-dev 7 | # 8 | 9 | #CXX = g++ 10 | #CXX = clang++ 11 | 12 | EXE = example_glut_opengl2 13 | IMGUI_DIR = ../.. 14 | SOURCES = main.cpp 15 | SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_tables.cpp $(IMGUI_DIR)/imgui_widgets.cpp 16 | SOURCES += $(IMGUI_DIR)/backends/imgui_impl_glut.cpp $(IMGUI_DIR)/backends/imgui_impl_opengl2.cpp 17 | OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES)))) 18 | UNAME_S := $(shell uname -s) 19 | 20 | CXXFLAGS = -std=c++11 -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends 21 | CXXFLAGS += -g -Wall -Wformat 22 | LIBS = 23 | 24 | ##--------------------------------------------------------------------- 25 | ## BUILD FLAGS PER PLATFORM 26 | ##--------------------------------------------------------------------- 27 | 28 | ifeq ($(UNAME_S), Linux) #LINUX 29 | ECHO_MESSAGE = "Linux" 30 | LIBS += -lGL -lglut 31 | CFLAGS = $(CXXFLAGS) 32 | endif 33 | 34 | ifeq ($(UNAME_S), Darwin) #APPLE 35 | ECHO_MESSAGE = "Mac OS X" 36 | LIBS += -framework OpenGL -framework GLUT 37 | LIBS += -L/usr/local/lib -L/opt/local/lib 38 | 39 | CXXFLAGS += -I/usr/local/include -I/opt/local/include 40 | CFLAGS = $(CXXFLAGS) 41 | endif 42 | 43 | ifeq ($(OS), Windows_NT) 44 | ECHO_MESSAGE = "MinGW" 45 | LIBS += -lgdi32 -lopengl32 -limm32 46 | ifeq ($(shell pkg-config freeglut --exists 2> /dev/null && echo yes || echo no),yes) 47 | CXXFLAGS += $(shell pkg-config freeglut --cflags) 48 | LIBS += $(shell pkg-config freeglut --libs) 49 | else 50 | LIBS += -lglut 51 | endif 52 | CFLAGS = $(CXXFLAGS) 53 | endif 54 | 55 | ##--------------------------------------------------------------------- 56 | ## BUILD RULES 57 | ##--------------------------------------------------------------------- 58 | 59 | %.o:%.cpp 60 | $(CXX) $(CXXFLAGS) -c -o $@ $< 61 | 62 | %.o:$(IMGUI_DIR)/%.cpp 63 | $(CXX) $(CXXFLAGS) -c -o $@ $< 64 | 65 | %.o:$(IMGUI_DIR)/backends/%.cpp 66 | $(CXX) $(CXXFLAGS) -c -o $@ $< 67 | 68 | all: $(EXE) 69 | @echo Build complete for $(ECHO_MESSAGE) 70 | 71 | $(EXE): $(OBJS) 72 | $(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS) 73 | 74 | clean: 75 | rm -f $(EXE) $(OBJS) 76 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_glut_opengl2/example_glut_opengl2.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {c336cfe3-f0c4-464c-9ef0-a9e17a7ff222} 6 | 7 | 8 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 9 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 10 | 11 | 12 | 13 | 14 | sources 15 | 16 | 17 | imgui 18 | 19 | 20 | imgui 21 | 22 | 23 | imgui 24 | 25 | 26 | imgui 27 | 28 | 29 | imgui 30 | 31 | 32 | sources 33 | 34 | 35 | sources 36 | 37 | 38 | 39 | 40 | imgui 41 | 42 | 43 | imgui 44 | 45 | 46 | imgui 47 | 48 | 49 | sources 50 | 51 | 52 | sources 53 | 54 | 55 | 56 | 57 | 58 | imgui 59 | 60 | 61 | imgui 62 | 63 | 64 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_null/build_win32.bat: -------------------------------------------------------------------------------- 1 | @REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler. 2 | mkdir Debug 3 | cl /nologo /Zi /MD /I ..\.. %* *.cpp ..\..\*.cpp /FeDebug/example_null.exe /FoDebug/ /link gdi32.lib shell32.lib imm32.lib 4 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_null/main.cpp: -------------------------------------------------------------------------------- 1 | // dear imgui: "null" example application 2 | // (compile and link imgui, create context, run headless with NO INPUTS, NO GRAPHICS OUTPUT) 3 | // This is useful to test building, but you cannot interact with anything here! 4 | #include "imgui.h" 5 | #include 6 | 7 | int main(int, char**) 8 | { 9 | IMGUI_CHECKVERSION(); 10 | ImGui::CreateContext(); 11 | ImGuiIO& io = ImGui::GetIO(); 12 | 13 | // Build atlas 14 | unsigned char* tex_pixels = NULL; 15 | int tex_w, tex_h; 16 | io.Fonts->GetTexDataAsRGBA32(&tex_pixels, &tex_w, &tex_h); 17 | 18 | for (int n = 0; n < 20; n++) 19 | { 20 | printf("NewFrame() %d\n", n); 21 | io.DisplaySize = ImVec2(1920, 1080); 22 | io.DeltaTime = 1.0f / 60.0f; 23 | ImGui::NewFrame(); 24 | 25 | static float f = 0.0f; 26 | ImGui::Text("Hello, world!"); 27 | ImGui::SliderFloat("float", &f, 0.0f, 1.0f); 28 | ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate); 29 | ImGui::ShowDemoWindow(NULL); 30 | 31 | ImGui::Render(); 32 | } 33 | 34 | printf("DestroyContext()\n"); 35 | ImGui::DestroyContext(); 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_sdl2_directx11/build_win32.bat: -------------------------------------------------------------------------------- 1 | @REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler. 2 | @set OUT_DIR=Debug 3 | @set OUT_EXE=example_sdl2_directx11 4 | @set INCLUDES=/I..\.. /I..\..\backends /I%SDL2_DIR%\include /I "%WindowsSdkDir%Include\um" /I "%WindowsSdkDir%Include\shared" /I "%DXSDK_DIR%Include" 5 | @set SOURCES=main.cpp ..\..\backends\imgui_impl_sdl2.cpp ..\..\backends\imgui_impl_dx11.cpp ..\..\imgui*.cpp 6 | @set LIBS=/LIBPATH:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib /LIBPATH:"%DXSDK_DIR%/Lib/x86" d3d11.lib d3dcompiler.lib shell32.lib 7 | mkdir %OUT_DIR% 8 | cl /nologo /Zi /MD %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% /subsystem:console 9 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_sdl2_directx11/example_sdl2_directx11.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {0587d7a3-f2ce-4d56-b84f-a0005d3bfce6} 6 | 7 | 8 | {08e36723-ce4f-4cff-9662-c40801cf1acf} 9 | 10 | 11 | 12 | 13 | imgui 14 | 15 | 16 | imgui 17 | 18 | 19 | imgui 20 | 21 | 22 | sources 23 | 24 | 25 | sources 26 | 27 | 28 | 29 | 30 | imgui 31 | 32 | 33 | sources 34 | 35 | 36 | imgui 37 | 38 | 39 | imgui 40 | 41 | 42 | imgui 43 | 44 | 45 | imgui 46 | 47 | 48 | sources 49 | 50 | 51 | sources 52 | 53 | 54 | 55 | 56 | 57 | imgui 58 | 59 | 60 | imgui 61 | 62 | 63 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_sdl2_metal/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # You will need SDL2 (http://www.libsdl.org): 3 | # brew install sdl2 4 | # 5 | 6 | #CXX = g++ 7 | #CXX = clang++ 8 | 9 | EXE = example_sdl2_metal 10 | IMGUI_DIR = ../.. 11 | SOURCES = main.mm 12 | SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_tables.cpp $(IMGUI_DIR)/imgui_widgets.cpp 13 | SOURCES += $(IMGUI_DIR)/backends/imgui_impl_sdl2.cpp $(IMGUI_DIR)/backends/imgui_impl_metal.mm 14 | OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES)))) 15 | 16 | LIBS = -framework Metal -framework MetalKit -framework Cocoa -framework IOKit -framework CoreVideo -framework QuartzCore 17 | LIBS += `sdl2-config --libs` 18 | LIBS += -L/usr/local/lib 19 | 20 | CXXFLAGS = -std=c++11 -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends -I/usr/local/include 21 | CXXFLAGS += `sdl2-config --cflags` 22 | CXXFLAGS += -Wall -Wformat 23 | CFLAGS = $(CXXFLAGS) 24 | 25 | %.o:%.cpp 26 | $(CXX) $(CXXFLAGS) -c -o $@ $< 27 | 28 | %.o:$(IMGUI_DIR)/%.cpp 29 | $(CXX) $(CXXFLAGS) -c -o $@ $< 30 | 31 | %.o:$(IMGUI_DIR)/backends/%.cpp 32 | $(CXX) $(CXXFLAGS) -c -o $@ $< 33 | 34 | %.o:%.mm 35 | $(CXX) $(CXXFLAGS) -ObjC++ -fobjc-weak -fobjc-arc -c -o $@ $< 36 | 37 | %.o:$(IMGUI_DIR)/backends/%.mm 38 | $(CXX) $(CXXFLAGS) -ObjC++ -fobjc-weak -fobjc-arc -c -o $@ $< 39 | 40 | all: $(EXE) 41 | @echo Build complete 42 | 43 | $(EXE): $(OBJS) 44 | $(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS) 45 | 46 | clean: 47 | rm -f $(EXE) $(OBJS) 48 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_sdl2_opengl2/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Cross Platform Makefile 3 | # Compatible with MSYS2/MINGW, Ubuntu 14.04.1 and Mac OS X 4 | # 5 | # You will need SDL2 (http://www.libsdl.org): 6 | # Linux: 7 | # apt-get install libsdl2-dev 8 | # Mac OS X: 9 | # brew install sdl2 10 | # MSYS2: 11 | # pacman -S mingw-w64-i686-SDL2 12 | # 13 | 14 | #CXX = g++ 15 | #CXX = clang++ 16 | 17 | EXE = example_sdl2_opengl2 18 | IMGUI_DIR = ../.. 19 | SOURCES = main.cpp 20 | SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_tables.cpp $(IMGUI_DIR)/imgui_widgets.cpp 21 | SOURCES += $(IMGUI_DIR)/backends/imgui_impl_sdl2.cpp $(IMGUI_DIR)/backends/imgui_impl_opengl2.cpp 22 | OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES)))) 23 | UNAME_S := $(shell uname -s) 24 | 25 | CXXFLAGS = -std=c++11 -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends 26 | CXXFLAGS += -g -Wall -Wformat 27 | LIBS = 28 | 29 | ##--------------------------------------------------------------------- 30 | ## BUILD FLAGS PER PLATFORM 31 | ##--------------------------------------------------------------------- 32 | 33 | ifeq ($(UNAME_S), Linux) #LINUX 34 | ECHO_MESSAGE = "Linux" 35 | LIBS += -lGL -ldl `sdl2-config --libs` 36 | 37 | CXXFLAGS += `sdl2-config --cflags` 38 | CFLAGS = $(CXXFLAGS) 39 | endif 40 | 41 | ifeq ($(UNAME_S), Darwin) #APPLE 42 | ECHO_MESSAGE = "Mac OS X" 43 | LIBS += -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo `sdl2-config --libs` 44 | LIBS += -L/usr/local/lib -L/opt/local/lib 45 | 46 | CXXFLAGS += `sdl2-config --cflags` 47 | CXXFLAGS += -I/usr/local/include -I/opt/local/include 48 | CFLAGS = $(CXXFLAGS) 49 | endif 50 | 51 | ifeq ($(OS), Windows_NT) 52 | ECHO_MESSAGE = "MinGW" 53 | LIBS += -lgdi32 -lopengl32 -limm32 `pkg-config --static --libs sdl2` 54 | 55 | CXXFLAGS += `pkg-config --cflags sdl2` 56 | CFLAGS = $(CXXFLAGS) 57 | endif 58 | 59 | ##--------------------------------------------------------------------- 60 | ## BUILD RULES 61 | ##--------------------------------------------------------------------- 62 | 63 | %.o:%.cpp 64 | $(CXX) $(CXXFLAGS) -c -o $@ $< 65 | 66 | %.o:$(IMGUI_DIR)/%.cpp 67 | $(CXX) $(CXXFLAGS) -c -o $@ $< 68 | 69 | %.o:$(IMGUI_DIR)/backends/%.cpp 70 | $(CXX) $(CXXFLAGS) -c -o $@ $< 71 | 72 | all: $(EXE) 73 | @echo Build complete for $(ECHO_MESSAGE) 74 | 75 | $(EXE): $(OBJS) 76 | $(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS) 77 | 78 | clean: 79 | rm -f $(EXE) $(OBJS) 80 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_sdl2_opengl2/README.md: -------------------------------------------------------------------------------- 1 | 2 | # How to Build 3 | 4 | - On Windows with Visual Studio's IDE 5 | 6 | Use the provided project file (.vcxproj). Add to solution (imgui_examples.sln) if necessary. 7 | 8 | - On Windows with Visual Studio's CLI 9 | 10 | ``` 11 | set SDL2_DIR=path_to_your_sdl2_folder 12 | cl /Zi /MD /I.. /I..\.. /I%SDL2_DIR%\include main.cpp ..\..\backends\imgui_impl_sdl2.cpp ..\..\backends\imgui_impl_opengl2.cpp ..\..\imgui*.cpp /FeDebug/example_sdl2_opengl2.exe /FoDebug/ /link /libpath:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib opengl32.lib /subsystem:console 13 | # ^^ include paths ^^ source files ^^ output exe ^^ output dir ^^ libraries 14 | # or for 64-bit: 15 | cl /Zi /MD /I.. /I..\.. /I%SDL2_DIR%\include main.cpp ..\..\backends\imgui_impl_sdl2.cpp ..\..\backends\imgui_impl_opengl2.cpp ..\..\imgui*.cpp /FeDebug/example_sdl2_opengl2.exe /FoDebug/ /link /libpath:%SDL2_DIR%\lib\x64 SDL2.lib SDL2main.lib opengl32.lib /subsystem:console 16 | ``` 17 | 18 | - On Linux and similar Unixes 19 | 20 | ``` 21 | c++ `sdl2-config --cflags` -I .. -I ../.. -I ../../backends main.cpp ../../backends/imgui_impl_sdl2.cpp ../../backends/imgui_impl_opengl2.cpp ../../imgui*.cpp `sdl2-config --libs` -lGL 22 | ``` 23 | 24 | - On Mac OS X 25 | 26 | ``` 27 | brew install sdl2 28 | c++ `sdl2-config --cflags` -I .. -I ../.. -I ../../backends main.cpp ../../backends/imgui_impl_sdl2.cpp ../../backends/imgui_impl_opengl2.cpp ../../imgui*.cpp `sdl2-config --libs` -framework OpenGl 29 | ``` 30 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_sdl2_opengl2/build_win32.bat: -------------------------------------------------------------------------------- 1 | @REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler. 2 | @set OUT_DIR=Debug 3 | @set OUT_EXE=example_sdl2_opengl2 4 | @set INCLUDES=/I..\.. /I..\..\backends /I%SDL2_DIR%\include 5 | @set SOURCES=main.cpp ..\..\backends\imgui_impl_sdl2.cpp ..\..\backends\imgui_impl_opengl2.cpp ..\..\imgui*.cpp 6 | @set LIBS=/LIBPATH:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib opengl32.lib shell32.lib 7 | mkdir %OUT_DIR% 8 | cl /nologo /Zi /MD %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% /subsystem:console 9 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_sdl2_opengl2/example_sdl2_opengl2.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {20b90ce4-7fcb-4731-b9a0-075f875de82d} 6 | 7 | 8 | {f18ab499-84e1-499f-8eff-9754361e0e52} 9 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 10 | 11 | 12 | 13 | 14 | imgui 15 | 16 | 17 | imgui 18 | 19 | 20 | imgui 21 | 22 | 23 | sources 24 | 25 | 26 | imgui 27 | 28 | 29 | imgui 30 | 31 | 32 | sources 33 | 34 | 35 | sources 36 | 37 | 38 | 39 | 40 | imgui 41 | 42 | 43 | imgui 44 | 45 | 46 | imgui 47 | 48 | 49 | sources 50 | 51 | 52 | sources 53 | 54 | 55 | 56 | 57 | 58 | imgui 59 | 60 | 61 | imgui 62 | 63 | 64 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_sdl2_opengl3/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Cross Platform Makefile 3 | # Compatible with MSYS2/MINGW, Ubuntu 14.04.1 and Mac OS X 4 | # 5 | # You will need SDL2 (http://www.libsdl.org): 6 | # Linux: 7 | # apt-get install libsdl2-dev 8 | # Mac OS X: 9 | # brew install sdl2 10 | # MSYS2: 11 | # pacman -S mingw-w64-i686-SDL2 12 | # 13 | 14 | #CXX = g++ 15 | #CXX = clang++ 16 | 17 | EXE = example_sdl2_opengl3 18 | IMGUI_DIR = ../.. 19 | SOURCES = main.cpp 20 | SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_tables.cpp $(IMGUI_DIR)/imgui_widgets.cpp 21 | SOURCES += $(IMGUI_DIR)/backends/imgui_impl_sdl2.cpp $(IMGUI_DIR)/backends/imgui_impl_opengl3.cpp 22 | OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES)))) 23 | UNAME_S := $(shell uname -s) 24 | LINUX_GL_LIBS = -lGL 25 | 26 | CXXFLAGS = -std=c++11 -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends 27 | CXXFLAGS += -g -Wall -Wformat 28 | LIBS = 29 | 30 | ##--------------------------------------------------------------------- 31 | ## OPENGL ES 32 | ##--------------------------------------------------------------------- 33 | 34 | ## This assumes a GL ES library available in the system, e.g. libGLESv2.so 35 | # CXXFLAGS += -DIMGUI_IMPL_OPENGL_ES2 36 | # LINUX_GL_LIBS = -lGLESv2 37 | ## If you're on a Raspberry Pi and want to use the legacy drivers, 38 | ## use the following instead: 39 | # LINUX_GL_LIBS = -L/opt/vc/lib -lbrcmGLESv2 40 | 41 | ##--------------------------------------------------------------------- 42 | ## BUILD FLAGS PER PLATFORM 43 | ##--------------------------------------------------------------------- 44 | 45 | ifeq ($(UNAME_S), Linux) #LINUX 46 | ECHO_MESSAGE = "Linux" 47 | LIBS += $(LINUX_GL_LIBS) -ldl `sdl2-config --libs` 48 | 49 | CXXFLAGS += `sdl2-config --cflags` 50 | CFLAGS = $(CXXFLAGS) 51 | endif 52 | 53 | ifeq ($(UNAME_S), Darwin) #APPLE 54 | ECHO_MESSAGE = "Mac OS X" 55 | LIBS += -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo `sdl2-config --libs` 56 | LIBS += -L/usr/local/lib -L/opt/local/lib 57 | 58 | CXXFLAGS += `sdl2-config --cflags` 59 | CXXFLAGS += -I/usr/local/include -I/opt/local/include 60 | CFLAGS = $(CXXFLAGS) 61 | endif 62 | 63 | ifeq ($(OS), Windows_NT) 64 | ECHO_MESSAGE = "MinGW" 65 | LIBS += -lgdi32 -lopengl32 -limm32 `pkg-config --static --libs sdl2` 66 | 67 | CXXFLAGS += `pkg-config --cflags sdl2` 68 | CFLAGS = $(CXXFLAGS) 69 | endif 70 | 71 | ##--------------------------------------------------------------------- 72 | ## BUILD RULES 73 | ##--------------------------------------------------------------------- 74 | 75 | %.o:%.cpp 76 | $(CXX) $(CXXFLAGS) -c -o $@ $< 77 | 78 | %.o:$(IMGUI_DIR)/%.cpp 79 | $(CXX) $(CXXFLAGS) -c -o $@ $< 80 | 81 | %.o:$(IMGUI_DIR)/backends/%.cpp 82 | $(CXX) $(CXXFLAGS) -c -o $@ $< 83 | 84 | all: $(EXE) 85 | @echo Build complete for $(ECHO_MESSAGE) 86 | 87 | $(EXE): $(OBJS) 88 | $(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS) 89 | 90 | clean: 91 | rm -f $(EXE) $(OBJS) 92 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_sdl2_opengl3/build_win32.bat: -------------------------------------------------------------------------------- 1 | @REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler. 2 | @set OUT_DIR=Debug 3 | @set OUT_EXE=example_sdl2_opengl3 4 | @set INCLUDES=/I..\.. /I..\..\backends /I%SDL2_DIR%\include 5 | @set SOURCES=main.cpp ..\..\backends\imgui_impl_sdl2.cpp ..\..\backends\imgui_impl_opengl3.cpp ..\..\imgui*.cpp 6 | @set LIBS=/LIBPATH:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib opengl32.lib shell32.lib 7 | mkdir %OUT_DIR% 8 | cl /nologo /Zi /MD %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% /subsystem:console 9 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_sdl2_opengl3/example_sdl2_opengl3.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {20b90ce4-7fcb-4731-b9a0-075f875de82d} 6 | 7 | 8 | {f18ab499-84e1-499f-8eff-9754361e0e52} 9 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 10 | 11 | 12 | 13 | 14 | imgui 15 | 16 | 17 | imgui 18 | 19 | 20 | imgui 21 | 22 | 23 | sources 24 | 25 | 26 | sources 27 | 28 | 29 | sources 30 | 31 | 32 | imgui 33 | 34 | 35 | imgui 36 | 37 | 38 | 39 | 40 | imgui 41 | 42 | 43 | imgui 44 | 45 | 46 | imgui 47 | 48 | 49 | sources 50 | 51 | 52 | sources 53 | 54 | 55 | sources 56 | 57 | 58 | 59 | 60 | 61 | imgui 62 | 63 | 64 | imgui 65 | 66 | 67 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_sdl2_sdlrenderer/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Cross Platform Makefile 3 | # Compatible with MSYS2/MINGW, Ubuntu 14.04.1 and Mac OS X 4 | # 5 | # You will need SDL2 (http://www.libsdl.org): 6 | # Linux: 7 | # apt-get install libsdl2-dev 8 | # Mac OS X: 9 | # brew install sdl2 10 | # MSYS2: 11 | # pacman -S mingw-w64-i686-SDL2 12 | # 13 | 14 | #CXX = g++ 15 | #CXX = clang++ 16 | 17 | EXE = example_sdl2_sdlrenderer 18 | IMGUI_DIR = ../.. 19 | SOURCES = main.cpp 20 | SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_tables.cpp $(IMGUI_DIR)/imgui_widgets.cpp 21 | SOURCES += $(IMGUI_DIR)/backends/imgui_impl_sdl2.cpp $(IMGUI_DIR)/backends/imgui_impl_sdlrenderer.cpp 22 | OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES)))) 23 | UNAME_S := $(shell uname -s) 24 | 25 | CXXFLAGS = -std=c++11 -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends 26 | CXXFLAGS += -g -Wall -Wformat 27 | LIBS = 28 | 29 | ##--------------------------------------------------------------------- 30 | ## BUILD FLAGS PER PLATFORM 31 | ##--------------------------------------------------------------------- 32 | 33 | ifeq ($(UNAME_S), Linux) #LINUX 34 | ECHO_MESSAGE = "Linux" 35 | LIBS += -lGL -ldl `sdl2-config --libs` 36 | 37 | CXXFLAGS += `sdl2-config --cflags` 38 | CFLAGS = $(CXXFLAGS) 39 | endif 40 | 41 | ifeq ($(UNAME_S), Darwin) #APPLE 42 | ECHO_MESSAGE = "Mac OS X" 43 | LIBS += -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo `sdl2-config --libs` 44 | LIBS += -L/usr/local/lib -L/opt/local/lib 45 | 46 | CXXFLAGS += `sdl2-config --cflags` 47 | CXXFLAGS += -I/usr/local/include -I/opt/local/include 48 | CFLAGS = $(CXXFLAGS) 49 | endif 50 | 51 | ifeq ($(OS), Windows_NT) 52 | ECHO_MESSAGE = "MinGW" 53 | LIBS += -lgdi32 -lopengl32 -limm32 `pkg-config --static --libs sdl2` 54 | 55 | CXXFLAGS += `pkg-config --cflags sdl2` 56 | CFLAGS = $(CXXFLAGS) 57 | endif 58 | 59 | ##--------------------------------------------------------------------- 60 | ## BUILD RULES 61 | ##--------------------------------------------------------------------- 62 | 63 | %.o:%.cpp 64 | $(CXX) $(CXXFLAGS) -c -o $@ $< 65 | 66 | %.o:$(IMGUI_DIR)/%.cpp 67 | $(CXX) $(CXXFLAGS) -c -o $@ $< 68 | 69 | %.o:$(IMGUI_DIR)/backends/%.cpp 70 | $(CXX) $(CXXFLAGS) -c -o $@ $< 71 | 72 | all: $(EXE) 73 | @echo Build complete for $(ECHO_MESSAGE) 74 | 75 | $(EXE): $(OBJS) 76 | $(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS) 77 | 78 | clean: 79 | rm -f $(EXE) $(OBJS) 80 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_sdl2_sdlrenderer/README.md: -------------------------------------------------------------------------------- 1 | 2 | # How to Build 3 | 4 | - On Windows with Visual Studio's CLI 5 | 6 | ``` 7 | set SDL2_DIR=path_to_your_sdl2_folder 8 | cl /Zi /MD /I.. /I..\.. /I%SDL2_DIR%\include main.cpp ..\..\backends\imgui_impl_sdl2.cpp ..\..\backends\imgui_impl_sdlrenderer.cpp ..\..\imgui*.cpp /FeDebug/example_sdl2_sdlrenderer.exe /FoDebug/ /link /libpath:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib /subsystem:console 9 | # ^^ include paths ^^ source files ^^ output exe ^^ output dir ^^ libraries 10 | # or for 64-bit: 11 | cl /Zi /MD /I.. /I..\.. /I%SDL2_DIR%\include main.cpp ..\..\backends\imgui_impl_sdl2.cpp ..\..\backends\imgui_impl_sdlrenderer.cpp ..\..\imgui*.cpp /FeDebug/example_sdl2_sdlrenderer.exe /FoDebug/ /link /libpath:%SDL2_DIR%\lib\x64 SDL2.lib SDL2main.lib /subsystem:console 12 | ``` 13 | 14 | - On Linux and similar Unixes 15 | 16 | ``` 17 | c++ `sdl2-config --cflags` -I .. -I ../.. main.cpp ../../backends/imgui_impl_sdl2.cpp ../../backends/imgui_impl_sdlrenderer.cpp ../../imgui*.cpp `sdl2-config --libs` -lGL 18 | ``` 19 | 20 | - On Mac OS X 21 | 22 | ``` 23 | brew install sdl2 24 | c++ `sdl2-config --cflags` -I .. -I ../.. main.cpp ../../backends/imgui_impl_sdl2.cpp ../../backends/imgui_impl_sdlrenderer.cpp ../../imgui*.cpp `sdl2-config --libs` -framework OpenGl 25 | ``` 26 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_sdl2_sdlrenderer/build_win32.bat: -------------------------------------------------------------------------------- 1 | @REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler. 2 | @set OUT_DIR=Debug 3 | @set OUT_EXE=example_sdl2_sdlrenderer_ 4 | @set INCLUDES=/I..\.. /I..\..\backends /I%SDL2_DIR%\include 5 | @set SOURCES=main.cpp ..\..\backends\imgui_impl_sdl2.cpp ..\..\backends\imgui_impl_sdlrenderer.cpp ..\..\imgui*.cpp 6 | @set LIBS=/LIBPATH:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib 7 | mkdir %OUT_DIR% 8 | cl /nologo /Zi /MD %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% /subsystem:console 9 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_sdl2_sdlrenderer/example_sdl2_sdlrenderer.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {20b90ce4-7fcb-4731-b9a0-075f875de82d} 6 | 7 | 8 | {f18ab499-84e1-499f-8eff-9754361e0e52} 9 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 10 | 11 | 12 | 13 | 14 | imgui 15 | 16 | 17 | imgui 18 | 19 | 20 | imgui 21 | 22 | 23 | sources 24 | 25 | 26 | imgui 27 | 28 | 29 | imgui 30 | 31 | 32 | sources 33 | 34 | 35 | sources 36 | 37 | 38 | 39 | 40 | imgui 41 | 42 | 43 | imgui 44 | 45 | 46 | imgui 47 | 48 | 49 | sources 50 | 51 | 52 | sources 53 | 54 | 55 | 56 | 57 | 58 | imgui 59 | 60 | 61 | imgui 62 | 63 | 64 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_sdl2_vulkan/build_win32.bat: -------------------------------------------------------------------------------- 1 | @REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler. 2 | 3 | @set OUT_EXE=example_sdl2_vulkan 4 | @set INCLUDES=/I..\.. /I..\..\backends /I%SDL2_DIR%\include /I %VULKAN_SDK%\include 5 | @set SOURCES=main.cpp ..\..\backends\imgui_impl_sdl2.cpp ..\..\backends\imgui_impl_vulkan.cpp ..\..\imgui*.cpp 6 | @set LIBS=/LIBPATH:%SDL2_DIR%\lib\x86 /libpath:%VULKAN_SDK%\lib32 SDL2.lib SDL2main.lib shell32.lib vulkan-1.lib 7 | 8 | @set OUT_DIR=Debug 9 | mkdir %OUT_DIR% 10 | cl /nologo /Zi /MD %INCLUDES% /D ImTextureID=ImU64 %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% /subsystem:console 11 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_sdl2_vulkan/example_sdl2_vulkan.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {20b90ce4-7fcb-4731-b9a0-075f875de82d} 6 | 7 | 8 | {f18ab499-84e1-499f-8eff-9754361e0e52} 9 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 10 | 11 | 12 | 13 | 14 | imgui 15 | 16 | 17 | imgui 18 | 19 | 20 | imgui 21 | 22 | 23 | sources 24 | 25 | 26 | sources 27 | 28 | 29 | sources 30 | 31 | 32 | imgui 33 | 34 | 35 | imgui 36 | 37 | 38 | 39 | 40 | imgui 41 | 42 | 43 | imgui 44 | 45 | 46 | imgui 47 | 48 | 49 | sources 50 | 51 | 52 | sources 53 | 54 | 55 | 56 | 57 | 58 | imgui 59 | 60 | 61 | imgui 62 | 63 | 64 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_sdl3_opengl3/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Cross Platform Makefile 3 | # Compatible with MSYS2/MINGW, Ubuntu 14.04.1 and Mac OS X 4 | # 5 | # You will need SDL3 (http://www.libsdl.org) which is still unreleased/unpackaged. 6 | 7 | #CXX = g++ 8 | #CXX = clang++ 9 | 10 | EXE = example_sdl3_opengl3 11 | IMGUI_DIR = ../.. 12 | SOURCES = main.cpp 13 | SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_tables.cpp $(IMGUI_DIR)/imgui_widgets.cpp 14 | SOURCES += $(IMGUI_DIR)/backends/imgui_impl_sdl3.cpp $(IMGUI_DIR)/backends/imgui_impl_opengl3.cpp 15 | OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES)))) 16 | UNAME_S := $(shell uname -s) 17 | LINUX_GL_LIBS = -lGL 18 | 19 | CXXFLAGS = -std=c++11 -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends 20 | CXXFLAGS += -g -Wall -Wformat 21 | LIBS = 22 | 23 | ##--------------------------------------------------------------------- 24 | ## OPENGL ES 25 | ##--------------------------------------------------------------------- 26 | 27 | ## This assumes a GL ES library available in the system, e.g. libGLESv2.so 28 | # CXXFLAGS += -DIMGUI_IMPL_OPENGL_ES2 29 | # LINUX_GL_LIBS = -lGLESv2 30 | ## If you're on a Raspberry Pi and want to use the legacy drivers, 31 | ## use the following instead: 32 | # LINUX_GL_LIBS = -L/opt/vc/lib -lbrcmGLESv2 33 | 34 | ##--------------------------------------------------------------------- 35 | ## BUILD FLAGS PER PLATFORM 36 | ##--------------------------------------------------------------------- 37 | 38 | ifeq ($(UNAME_S), Linux) #LINUX 39 | ECHO_MESSAGE = "Linux" 40 | LIBS += $(LINUX_GL_LIBS) -ldl `sdl3-config --libs` 41 | 42 | CXXFLAGS += `sdl3-config --cflags` 43 | CFLAGS = $(CXXFLAGS) 44 | endif 45 | 46 | ifeq ($(UNAME_S), Darwin) #APPLE 47 | ECHO_MESSAGE = "Mac OS X" 48 | LIBS += -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo `sdl3-config --libs` 49 | LIBS += -L/usr/local/lib -L/opt/local/lib 50 | 51 | CXXFLAGS += `sdl3-config --cflags` 52 | CXXFLAGS += -I/usr/local/include -I/opt/local/include 53 | CFLAGS = $(CXXFLAGS) 54 | endif 55 | 56 | ifeq ($(OS), Windows_NT) 57 | ECHO_MESSAGE = "MinGW" 58 | LIBS += -lgdi32 -lopengl32 -limm32 `pkg-config --static --libs sdl3` 59 | 60 | CXXFLAGS += `pkg-config --cflags sdl3` 61 | CFLAGS = $(CXXFLAGS) 62 | endif 63 | 64 | ##--------------------------------------------------------------------- 65 | ## BUILD RULES 66 | ##--------------------------------------------------------------------- 67 | 68 | %.o:%.cpp 69 | $(CXX) $(CXXFLAGS) -c -o $@ $< 70 | 71 | %.o:$(IMGUI_DIR)/%.cpp 72 | $(CXX) $(CXXFLAGS) -c -o $@ $< 73 | 74 | %.o:$(IMGUI_DIR)/backends/%.cpp 75 | $(CXX) $(CXXFLAGS) -c -o $@ $< 76 | 77 | all: $(EXE) 78 | @echo Build complete for $(ECHO_MESSAGE) 79 | 80 | $(EXE): $(OBJS) 81 | $(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS) 82 | 83 | clean: 84 | rm -f $(EXE) $(OBJS) 85 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_sdl3_opengl3/build_win32.bat: -------------------------------------------------------------------------------- 1 | @REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler. 2 | @set OUT_DIR=Debug 3 | @set OUT_EXE=example_sdl3_opengl3 4 | @set INCLUDES=/I..\.. /I..\..\backends /I%SDL3_DIR%\include 5 | @set SOURCES=main.cpp ..\..\backends\imgui_impl_sdl3.cpp ..\..\backends\imgui_impl_opengl3.cpp ..\..\imgui*.cpp 6 | @set LIBS=/LIBPATH:%SDL3_DIR%\lib\x86 SDL3.lib opengl32.lib shell32.lib 7 | mkdir %OUT_DIR% 8 | cl /nologo /Zi /MD %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% /subsystem:console 9 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_sdl3_opengl3/example_sdl3_opengl3.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {20b90ce4-7fcb-4731-b9a0-075f875de82d} 6 | 7 | 8 | {f18ab499-84e1-499f-8eff-9754361e0e52} 9 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 10 | 11 | 12 | 13 | 14 | imgui 15 | 16 | 17 | imgui 18 | 19 | 20 | imgui 21 | 22 | 23 | sources 24 | 25 | 26 | sources 27 | 28 | 29 | sources 30 | 31 | 32 | imgui 33 | 34 | 35 | imgui 36 | 37 | 38 | 39 | 40 | imgui 41 | 42 | 43 | imgui 44 | 45 | 46 | imgui 47 | 48 | 49 | sources 50 | 51 | 52 | sources 53 | 54 | 55 | sources 56 | 57 | 58 | 59 | 60 | 61 | imgui 62 | 63 | 64 | imgui 65 | 66 | 67 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_win32_directx10/build_win32.bat: -------------------------------------------------------------------------------- 1 | @REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler. 2 | @set OUT_DIR=Debug 3 | @set OUT_EXE=example_win32_directx10 4 | @set INCLUDES=/I..\.. /I..\..\backends /I "%WindowsSdkDir%Include\um" /I "%WindowsSdkDir%Include\shared" /I "%DXSDK_DIR%Include" 5 | @set SOURCES=main.cpp ..\..\backends\imgui_impl_win32.cpp ..\..\backends\imgui_impl_dx10.cpp ..\..\imgui*.cpp 6 | @set LIBS=/LIBPATH:"%DXSDK_DIR%/Lib/x86" d3d10.lib d3dcompiler.lib 7 | mkdir %OUT_DIR% 8 | cl /nologo /Zi /MD %INCLUDES% /D UNICODE /D _UNICODE %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% 9 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_win32_directx10/example_win32_directx10.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {0587d7a3-f2ce-4d56-b84f-a0005d3bfce6} 6 | 7 | 8 | {08e36723-ce4f-4cff-9662-c40801cf1acf} 9 | 10 | 11 | 12 | 13 | imgui 14 | 15 | 16 | imgui 17 | 18 | 19 | imgui 20 | 21 | 22 | sources 23 | 24 | 25 | sources 26 | 27 | 28 | 29 | 30 | imgui 31 | 32 | 33 | sources 34 | 35 | 36 | imgui 37 | 38 | 39 | imgui 40 | 41 | 42 | sources 43 | 44 | 45 | sources 46 | 47 | 48 | imgui 49 | 50 | 51 | imgui 52 | 53 | 54 | 55 | 56 | 57 | imgui 58 | 59 | 60 | imgui 61 | 62 | 63 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_win32_directx11/build_win32.bat: -------------------------------------------------------------------------------- 1 | @REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler. 2 | @set OUT_DIR=Debug 3 | @set OUT_EXE=example_win32_directx11 4 | @set INCLUDES=/I..\.. /I..\..\backends /I "%WindowsSdkDir%Include\um" /I "%WindowsSdkDir%Include\shared" /I "%DXSDK_DIR%Include" 5 | @set SOURCES=main.cpp ..\..\backends\imgui_impl_dx11.cpp ..\..\backends\imgui_impl_win32.cpp ..\..\imgui*.cpp 6 | @set LIBS=/LIBPATH:"%DXSDK_DIR%/Lib/x86" d3d11.lib d3dcompiler.lib 7 | mkdir %OUT_DIR% 8 | cl /nologo /Zi /MD %INCLUDES% /D UNICODE /D _UNICODE %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% 9 | 10 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_win32_directx11/example_win32_directx11.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {0587d7a3-f2ce-4d56-b84f-a0005d3bfce6} 6 | 7 | 8 | {08e36723-ce4f-4cff-9662-c40801cf1acf} 9 | 10 | 11 | 12 | 13 | imgui 14 | 15 | 16 | imgui 17 | 18 | 19 | imgui 20 | 21 | 22 | sources 23 | 24 | 25 | sources 26 | 27 | 28 | 29 | 30 | imgui 31 | 32 | 33 | sources 34 | 35 | 36 | imgui 37 | 38 | 39 | imgui 40 | 41 | 42 | imgui 43 | 44 | 45 | sources 46 | 47 | 48 | sources 49 | 50 | 51 | imgui 52 | 53 | 54 | 55 | 56 | 57 | imgui 58 | 59 | 60 | imgui 61 | 62 | 63 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_win32_directx12/build_win32.bat: -------------------------------------------------------------------------------- 1 | @REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler. 2 | @REM Important: to build on 32-bit systems, the DX12 backends needs '#define ImTextureID ImU64', so we pass it here. 3 | @set OUT_DIR=Debug 4 | @set OUT_EXE=example_win32_directx12 5 | @set INCLUDES=/I..\.. /I..\..\backends /I "%WindowsSdkDir%Include\um" /I "%WindowsSdkDir%Include\shared" 6 | @set SOURCES=main.cpp ..\..\backends\imgui_impl_dx12.cpp ..\..\backends\imgui_impl_win32.cpp ..\..\imgui*.cpp 7 | @set LIBS=d3d12.lib d3dcompiler.lib dxgi.lib 8 | mkdir Debug 9 | cl /nologo /Zi /MD %INCLUDES% /D ImTextureID=ImU64 /D UNICODE /D _UNICODE %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% 10 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_win32_directx12/example_win32_directx12.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {fb3d294f-51ec-478e-a627-25831c80fefd} 6 | 7 | 8 | {4f33ddea-9910-456d-b868-4267eb3c2b19} 9 | 10 | 11 | 12 | 13 | imgui 14 | 15 | 16 | imgui 17 | 18 | 19 | imgui 20 | 21 | 22 | sources 23 | 24 | 25 | sources 26 | 27 | 28 | 29 | 30 | imgui 31 | 32 | 33 | sources 34 | 35 | 36 | imgui 37 | 38 | 39 | imgui 40 | 41 | 42 | sources 43 | 44 | 45 | sources 46 | 47 | 48 | imgui 49 | 50 | 51 | imgui 52 | 53 | 54 | 55 | 56 | 57 | imgui 58 | 59 | 60 | 61 | 62 | imgui 63 | 64 | 65 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_win32_directx9/build_win32.bat: -------------------------------------------------------------------------------- 1 | @REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler. 2 | @set OUT_DIR=Debug 3 | @set OUT_EXE=example_win32_directx9 4 | @set INCLUDES=/I..\.. /I..\..\backends /I "%DXSDK_DIR%/Include" 5 | @set SOURCES=main.cpp ..\..\backends\imgui_impl_dx9.cpp ..\..\backends\imgui_impl_win32.cpp ..\..\imgui*.cpp 6 | @set LIBS=/LIBPATH:"%DXSDK_DIR%/Lib/x86" d3d9.lib 7 | mkdir %OUT_DIR% 8 | cl /nologo /Zi /MD %INCLUDES% /D UNICODE /D _UNICODE %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% 9 | -------------------------------------------------------------------------------- /Demo/imgui/examples/example_win32_directx9/example_win32_directx9.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {a82cba23-9de0-45c2-b1e3-2eb1666702de} 10 | 11 | 12 | 13 | 14 | sources 15 | 16 | 17 | imgui 18 | 19 | 20 | imgui 21 | 22 | 23 | imgui 24 | 25 | 26 | sources 27 | 28 | 29 | sources 30 | 31 | 32 | imgui 33 | 34 | 35 | imgui 36 | 37 | 38 | 39 | 40 | imgui 41 | 42 | 43 | imgui 44 | 45 | 46 | imgui 47 | 48 | 49 | sources 50 | 51 | 52 | sources 53 | 54 | 55 | 56 | 57 | 58 | imgui 59 | 60 | 61 | imgui 62 | 63 | 64 | -------------------------------------------------------------------------------- /Demo/imgui/examples/libs/emscripten/emscripten_mainloop_stub.h: -------------------------------------------------------------------------------- 1 | // What does this file solves? 2 | // - Since Dear ImGui 1.00 we took pride that most of our examples applications had their entire 3 | // main-loop inside the main() function. That's because: 4 | // - It makes the examples easier to read, keeping the code sequential. 5 | // - It permit the use of local variables, making it easier to try things and perform quick 6 | // changes when someone needs to quickly test something (vs having to structure the example 7 | // in order to pass data around). This is very important because people use those examples 8 | // to craft easy-to-past repro when they want to discuss features or report issues. 9 | // - It conveys at a glance that this is a no-BS framework, it won't take your main loop away from you. 10 | // - It is generally nice and elegant. 11 | // - However, comes Emscripten... it is a wonderful and magical tech but it requires a "main loop" function. 12 | // - Only some of our examples would run on Emscripten. Typically the ones rendering with GL or WGPU ones. 13 | // - I tried to refactor those examples but felt it was problematic that other examples didn't follow the 14 | // same layout. Why would the SDL+GL example be structured one way and the SGL+DX11 be structured differently? 15 | // Especially as we are trying hard to convey that using a Dear ImGui backend in an *existing application* 16 | // should requires only a few dozens lines of code, and this should be consistent and symmetrical for all backends. 17 | // - So the next logical step was to refactor all examples to follow that layout of using a "main loop" function. 18 | // This worked, but it made us lose all the nice things we had... 19 | 20 | // Since only about 3 examples really need to run with Emscripten, here's our solution: 21 | // - Use some weird macros and capturing lambda to turn a loop in main() into a function. 22 | // - Hide all that crap in this file so it doesn't make our examples unusually ugly. 23 | // As a stance and principle of Dear ImGui development we don't use C++ headers and we don't 24 | // want to suggest to the newcomer that we would ever use C++ headers as this would affect 25 | // the initial judgment of many of our target audience. 26 | // - Technique is based on this idea: https://github.com/ocornut/imgui/pull/2492/ 27 | #ifdef __EMSCRIPTEN__ 28 | #include 29 | #include 30 | static std::function MainLoopForEmscriptenP; 31 | static void MainLoopForEmscripten() { MainLoopForEmscriptenP(); } 32 | #define EMSCRIPTEN_MAINLOOP_BEGIN MainLoopForEmscriptenP = [&]() 33 | #define EMSCRIPTEN_MAINLOOP_END ; emscripten_set_main_loop(MainLoopForEmscripten, 0, true) 34 | #else 35 | #define EMSCRIPTEN_MAINLOOP_BEGIN 36 | #define EMSCRIPTEN_MAINLOOP_END 37 | #endif 38 | -------------------------------------------------------------------------------- /Demo/imgui/examples/libs/emscripten/shell_minimal.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Dear ImGui Emscripten example 7 | 30 | 31 | 32 | 33 | 63 | {{{ SCRIPT }}} 64 | 65 | 66 | -------------------------------------------------------------------------------- /Demo/imgui/examples/libs/glfw/COPYING.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2002-2006 Marcus Geelnard 2 | Copyright (c) 2006-2010 Camilla Berglund 3 | 4 | This software is provided 'as-is', without any express or implied 5 | warranty. In no event will the authors be held liable for any damages 6 | arising from the use of this software. 7 | 8 | Permission is granted to anyone to use this software for any purpose, 9 | including commercial applications, and to alter it and redistribute it 10 | freely, subject to the following restrictions: 11 | 12 | 1. The origin of this software must not be misrepresented; you must not 13 | claim that you wrote the original software. If you use this software 14 | in a product, an acknowledgment in the product documentation would 15 | be appreciated but is not required. 16 | 17 | 2. Altered source versions must be plainly marked as such, and must not 18 | be misrepresented as being the original software. 19 | 20 | 3. This notice may not be removed or altered from any source 21 | distribution. 22 | 23 | -------------------------------------------------------------------------------- /Demo/imgui/examples/libs/glfw/lib-vc2010-32/glfw3.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronicarts/cpp-ml-intro/682222d9993d122749723b54d8d6064d6117288a/Demo/imgui/examples/libs/glfw/lib-vc2010-32/glfw3.lib -------------------------------------------------------------------------------- /Demo/imgui/examples/libs/glfw/lib-vc2010-64/glfw3.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronicarts/cpp-ml-intro/682222d9993d122749723b54d8d6064d6117288a/Demo/imgui/examples/libs/glfw/lib-vc2010-64/glfw3.lib -------------------------------------------------------------------------------- /Demo/imgui/examples/libs/usynergy/README.txt: -------------------------------------------------------------------------------- 1 | 2 | uSynergy client -- Implementation for the embedded Synergy client library 3 | version 1.0.0, July 7th, 2012 4 | Copyright (c) 2012 Alex Evans 5 | 6 | This is a copy of the files once found at: 7 | https://github.com/symless/synergy-core/tree/790d108a56ada9caad8e56ff777d444485a69da9/src/micro 8 | 9 | -------------------------------------------------------------------------------- /Demo/imgui/misc/README.txt: -------------------------------------------------------------------------------- 1 | 2 | misc/cpp/ 3 | InputText() wrappers for C++ standard library (STL) type: std::string. 4 | This is also an example of how you may wrap your own similar types. 5 | 6 | misc/debuggers/ 7 | Helper files for popular debuggers. 8 | With the .natvis file, types like ImVector<> will be displayed nicely in Visual Studio debugger. 9 | 10 | misc/fonts/ 11 | Fonts loading/merging instructions (e.g. How to handle glyph ranges, how to merge icons fonts). 12 | Command line tool "binary_to_compressed_c" to create compressed arrays to embed data in source code. 13 | Suggested fonts and links. 14 | 15 | misc/freetype/ 16 | Font atlas builder/rasterizer using FreeType instead of stb_truetype. 17 | Benefit from better FreeType rasterization, in particular for small fonts. 18 | 19 | misc/single_file/ 20 | Single-file header stub. 21 | We use this to validate compiling all *.cpp files in a same compilation unit. 22 | Users of that technique (also called "Unity builds") can generally provide this themselves, 23 | so we don't really recommend you use this in your projects. 24 | -------------------------------------------------------------------------------- /Demo/imgui/misc/cpp/README.txt: -------------------------------------------------------------------------------- 1 | 2 | imgui_stdlib.h + imgui_stdlib.cpp 3 | InputText() wrappers for C++ standard library (STL) type: std::string. 4 | This is also an example of how you may wrap your own similar types. 5 | 6 | imgui_scoped.h 7 | [Experimental, not currently in main repository] 8 | Additional header file with some RAII-style wrappers for common Dear ImGui functions. 9 | Try by merging: https://github.com/ocornut/imgui/pull/2197 10 | Discuss at: https://github.com/ocornut/imgui/issues/2096 11 | 12 | See more C++ related extension (fmt, RAII, syntaxis sugar) on Wiki: 13 | https://github.com/ocornut/imgui/wiki/Useful-Extensions#cness 14 | -------------------------------------------------------------------------------- /Demo/imgui/misc/cpp/imgui_stdlib.h: -------------------------------------------------------------------------------- 1 | // dear imgui: wrappers for C++ standard library (STL) types (std::string, etc.) 2 | // This is also an example of how you may wrap your own similar types. 3 | 4 | // Changelog: 5 | // - v0.10: Initial version. Added InputText() / InputTextMultiline() calls with std::string 6 | 7 | // See more C++ related extension (fmt, RAII, syntaxis sugar) on Wiki: 8 | // https://github.com/ocornut/imgui/wiki/Useful-Extensions#cness 9 | 10 | #pragma once 11 | 12 | #include 13 | 14 | namespace ImGui 15 | { 16 | // ImGui::InputText() with std::string 17 | // Because text input needs dynamic resizing, we need to setup a callback to grow the capacity 18 | IMGUI_API bool InputText(const char* label, std::string* str, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL); 19 | IMGUI_API bool InputTextMultiline(const char* label, std::string* str, const ImVec2& size = ImVec2(0, 0), ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL); 20 | IMGUI_API bool InputTextWithHint(const char* label, const char* hint, std::string* str, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL); 21 | } 22 | -------------------------------------------------------------------------------- /Demo/imgui/misc/debuggers/README.txt: -------------------------------------------------------------------------------- 1 | 2 | HELPER FILES FOR POPULAR DEBUGGERS 3 | 4 | imgui.gdb 5 | GDB: disable stepping into trivial functions. 6 | (read comments inside file for details) 7 | 8 | imgui.natstepfilter 9 | Visual Studio Debugger: disable stepping into trivial functions. 10 | (read comments inside file for details) 11 | 12 | imgui.natvis 13 | Visual Studio Debugger: describe Dear ImGui types for better display. 14 | With this, types like ImVector<> will be displayed nicely in the debugger. 15 | (read comments inside file for details) 16 | 17 | -------------------------------------------------------------------------------- /Demo/imgui/misc/debuggers/imgui.gdb: -------------------------------------------------------------------------------- 1 | # GDB configuration to aid debugging experience 2 | 3 | # To enable these customizations edit $HOME/.gdbinit (or ./.gdbinit if local gdbinit is enabled) and add: 4 | # add-auto-load-safe-path /path/to/imgui.gdb 5 | # source /path/to/imgui.gdb 6 | # 7 | # More Information at: 8 | # * https://sourceware.org/gdb/current/onlinedocs/gdb/gdbinit-man.html 9 | # * https://sourceware.org/gdb/current/onlinedocs/gdb/Init-File-in-the-Current-Directory.html#Init-File-in-the-Current-Directory 10 | 11 | # Disable stepping into trivial functions 12 | skip -rfunction Im(Vec2|Vec4|Strv|Vector|Span)::.+ 13 | -------------------------------------------------------------------------------- /Demo/imgui/misc/debuggers/imgui.natstepfilter: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | 23 | (ImVec2|ImVec4|ImStrv)::.+ 24 | NoStepInto 25 | 26 | 27 | (ImVector|ImSpan).*::operator.+ 28 | NoStepInto 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /Demo/imgui/misc/debuggers/imgui.natvis: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 15 | 16 | 17 | {{Size={Size} Capacity={Capacity}}} 18 | 19 | 20 | Size 21 | Data 22 | 23 | 24 | 25 | 26 | 27 | {{Size={DataEnd-Data} }} 28 | 29 | 30 | DataEnd-Data 31 | Data 32 | 33 | 34 | 35 | 36 | 37 | {{x={x,g} y={y,g}}} 38 | 39 | 40 | 41 | {{x={x,g} y={y,g} z={z,g} w={w,g}}} 42 | 43 | 44 | 45 | {{Min=({Min.x,g} {Min.y,g}) Max=({Max.x,g} {Max.y,g}) Size=({Max.x-Min.x,g} {Max.y-Min.y,g})}} 46 | 47 | Min 48 | Max 49 | Max.x - Min.x 50 | Max.y - Min.y 51 | 52 | 53 | 54 | 55 | {{Name {Name,s} Active {(Active||WasActive)?1:0,d} Child {(Flags & 0x01000000)?1:0,d} Popup {(Flags & 0x04000000)?1:0,d} Hidden {(Hidden)?1:0,d}} 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /Demo/imgui/misc/fonts/Cousine-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronicarts/cpp-ml-intro/682222d9993d122749723b54d8d6064d6117288a/Demo/imgui/misc/fonts/Cousine-Regular.ttf -------------------------------------------------------------------------------- /Demo/imgui/misc/fonts/DroidSans.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronicarts/cpp-ml-intro/682222d9993d122749723b54d8d6064d6117288a/Demo/imgui/misc/fonts/DroidSans.ttf -------------------------------------------------------------------------------- /Demo/imgui/misc/fonts/Karla-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronicarts/cpp-ml-intro/682222d9993d122749723b54d8d6064d6117288a/Demo/imgui/misc/fonts/Karla-Regular.ttf -------------------------------------------------------------------------------- /Demo/imgui/misc/fonts/ProggyClean.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronicarts/cpp-ml-intro/682222d9993d122749723b54d8d6064d6117288a/Demo/imgui/misc/fonts/ProggyClean.ttf -------------------------------------------------------------------------------- /Demo/imgui/misc/fonts/ProggyTiny.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronicarts/cpp-ml-intro/682222d9993d122749723b54d8d6064d6117288a/Demo/imgui/misc/fonts/ProggyTiny.ttf -------------------------------------------------------------------------------- /Demo/imgui/misc/fonts/Roboto-Medium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronicarts/cpp-ml-intro/682222d9993d122749723b54d8d6064d6117288a/Demo/imgui/misc/fonts/Roboto-Medium.ttf -------------------------------------------------------------------------------- /Demo/imgui/misc/freetype/README.md: -------------------------------------------------------------------------------- 1 | # imgui_freetype 2 | 3 | Build font atlases using FreeType instead of stb_truetype (which is the default font rasterizer). 4 |
by @vuhdo, @mikesart, @ocornut. 5 | 6 | ### Usage 7 | 8 | 1. Get latest FreeType binaries or build yourself (under Windows you may use vcpkg with `vcpkg install freetype --triplet=x64-windows`, `vcpkg integrate install`). 9 | 2. Add imgui_freetype.h/cpp alongside your project files. 10 | 3. Add `#define IMGUI_ENABLE_FREETYPE` in your [imconfig.h](https://github.com/ocornut/imgui/blob/master/imconfig.h) file 11 | 12 | ### About Gamma Correct Blending 13 | 14 | FreeType assumes blending in linear space rather than gamma space. 15 | See FreeType note for [FT_Render_Glyph](https://www.freetype.org/freetype2/docs/reference/ft2-base_interface.html#FT_Render_Glyph). 16 | For correct results you need to be using sRGB and convert to linear space in the pixel shader output. 17 | The default Dear ImGui styles will be impacted by this change (alpha values will need tweaking). 18 | 19 | ### Testbed for toying with settings (for developers) 20 | 21 | See https://gist.github.com/ocornut/b3a9ecf13502fd818799a452969649ad 22 | 23 | ### Known issues 24 | 25 | - Oversampling settins are ignored but also not so much necessary with the higher quality rendering. 26 | 27 | ### Comparison 28 | 29 | Small, thin anti-aliased fonts typically benefit a lot from FreeType's hinting: 30 | ![comparing_font_rasterizers](https://user-images.githubusercontent.com/8225057/107550178-fef87f00-6bd0-11eb-8d09-e2edb2f0ccfc.gif) 31 | 32 | ### Colorful glyphs/emojis 33 | 34 | You can use the `ImGuiFreeTypeBuilderFlags_LoadColor` flag to load certain colorful glyphs. See the 35 | ["Using Colorful Glyphs/Emojis"](https://github.com/ocornut/imgui/blob/master/docs/FONTS.md#using-colorful-glyphsemojis) section of FONTS.md. 36 | 37 | ![colored glyphs](https://user-images.githubusercontent.com/8225057/106171241-9dc4ba80-6191-11eb-8a69-ca1467b206d1.png) 38 | -------------------------------------------------------------------------------- /Demo/imgui/misc/single_file/imgui_single_file.h: -------------------------------------------------------------------------------- 1 | // dear imgui: single-file wrapper include 2 | // We use this to validate compiling all *.cpp files in a same compilation unit. 3 | // Users of that technique (also called "Unity builds") can generally provide this themselves, 4 | // so we don't really recommend you use this in your projects. 5 | 6 | // Do this: 7 | // #define IMGUI_IMPLEMENTATION 8 | // Before you include this file in *one* C++ file to create the implementation. 9 | // Using this in your project will leak the contents of imgui_internal.h and ImVec2 operators in this compilation unit. 10 | 11 | #ifdef IMGUI_IMPLEMENTATION 12 | #define IMGUI_DEFINE_MATH_OPERATORS 13 | #endif 14 | 15 | #include "../../imgui.h" 16 | #ifdef IMGUI_ENABLE_FREETYPE 17 | #include "../../misc/freetype/imgui_freetype.h" 18 | #endif 19 | 20 | #ifdef IMGUI_IMPLEMENTATION 21 | #include "../../imgui.cpp" 22 | #include "../../imgui_demo.cpp" 23 | #include "../../imgui_draw.cpp" 24 | #include "../../imgui_tables.cpp" 25 | #include "../../imgui_widgets.cpp" 26 | #ifdef IMGUI_ENABLE_FREETYPE 27 | #include "../../misc/freetype/imgui_freetype.cpp" 28 | #endif 29 | #endif 30 | -------------------------------------------------------------------------------- /Demo/mnist/DX12Utils/CompileShaders.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // Machine Learning Introduction For Game Developers // 3 | // Copyright (c) 2023 Electronic Arts Inc. All rights reserved. // 4 | /////////////////////////////////////////////////////////////////////////////// 5 | 6 | #pragma once 7 | 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | #include "DX12Utils/logfn.h" 14 | 15 | namespace DX12Utils 16 | { 17 | bool MakeComputePSO_DXC( 18 | ID3D12Device* device, 19 | LPCWSTR shaderDir, 20 | LPCWSTR shaderFile, 21 | const char* entryPoint, 22 | const char* shaderModel, 23 | const D3D_SHADER_MACRO* defines, 24 | ID3D12RootSignature* rootSig, 25 | ID3D12PipelineState** pso, 26 | bool debugShaders, 27 | LPCWSTR debugName, 28 | TLogFn logFn); 29 | 30 | bool MakeComputePSO_FXC( 31 | ID3D12Device* device, 32 | LPCWSTR shaderDir, 33 | LPCWSTR shaderFile, 34 | const char* entryPoint, 35 | const char* shaderModel, 36 | const D3D_SHADER_MACRO* defines, 37 | ID3D12RootSignature* rootSig, 38 | ID3D12PipelineState** pso, 39 | bool debugShaders, 40 | LPCWSTR debugName, 41 | TLogFn logFn); 42 | 43 | std::vector CompileShaderToByteCode_DXC( 44 | LPCWSTR shaderDir, 45 | LPCWSTR shaderFile, 46 | const char* entryPoint, 47 | const char* shaderModel, 48 | const D3D_SHADER_MACRO* defines, 49 | bool debugShaders, 50 | TLogFn logFn); 51 | 52 | std::vector CompileShaderToByteCode_FXC( 53 | LPCWSTR shaderDir, 54 | LPCWSTR shaderFile, 55 | const char* entryPoint, 56 | const char* shaderModel, 57 | const D3D_SHADER_MACRO* defines, 58 | bool debugShaders, 59 | TLogFn logFn); 60 | } -------------------------------------------------------------------------------- /Demo/mnist/DX12Utils/DelayedReleaseTracker.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // Machine Learning Introduction For Game Developers // 3 | // Copyright (c) 2023 Electronic Arts Inc. All rights reserved. // 4 | /////////////////////////////////////////////////////////////////////////////// 5 | 6 | #pragma once 7 | 8 | #include 9 | #include 10 | 11 | namespace DX12Utils 12 | { 13 | 14 | class DelayedReleaseTracker 15 | { 16 | public: 17 | void OnNewFrame(int maxFramesInFlight) 18 | { 19 | // advance the age of each object. Free them when it's safe to do so. 20 | m_objects.erase( 21 | std::remove_if(m_objects.begin(), m_objects.end(), 22 | [maxFramesInFlight](Object& object) 23 | { 24 | object.age++; 25 | if (object.age >= maxFramesInFlight) 26 | { 27 | object.object->Release(); 28 | return true; 29 | } 30 | return false; 31 | } 32 | ), 33 | m_objects.end() 34 | ); 35 | } 36 | 37 | void Add(ID3D12DeviceChild* object) 38 | { 39 | if (!object) 40 | return; 41 | 42 | m_objects.push_back({ object, 0 }); 43 | } 44 | 45 | void Release() 46 | { 47 | // This assumes there are no more frames in flight and that it's safe to release everything 48 | for (Object& object : m_objects) 49 | object.object->Release(); 50 | m_objects.clear(); 51 | } 52 | 53 | private: 54 | struct Object 55 | { 56 | ID3D12DeviceChild* object = nullptr; 57 | int age = 0; 58 | }; 59 | 60 | std::vector m_objects; 61 | }; 62 | 63 | }; // namespace DX12Utils -------------------------------------------------------------------------------- /Demo/mnist/DX12Utils/FileCache.cpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // Machine Learning Introduction For Game Developers // 3 | // Copyright (c) 2023 Electronic Arts Inc. All rights reserved. // 4 | /////////////////////////////////////////////////////////////////////////////// 5 | 6 | #include "FileCache.h" 7 | 8 | #include 9 | 10 | std::unordered_map DX12Utils::FileCache::s_cache; 11 | 12 | namespace DX12Utils 13 | { 14 | 15 | FileCache::File& FileCache::Get(const char* fileName) 16 | { 17 | // normalize the string by making it canonical and making it lower case 18 | std::string s = std::filesystem::weakly_canonical(fileName).string(); 19 | std::transform(s.begin(), s.end(), s.begin(), [](unsigned char c) { return std::tolower(c); }); 20 | 21 | // If we don't have an entry for this file, create one 22 | // Add an extra null character at the end for text files. 23 | // We'll report the size as size-1 to account for this. 24 | if (s_cache.count(s) == 0) 25 | { 26 | File newFile; 27 | 28 | FILE* file = nullptr; 29 | fopen_s(&file, s.c_str(), "rb"); 30 | if (file) 31 | { 32 | fseek(file, 0, SEEK_END); 33 | newFile.bytes.resize(ftell(file) + 1); 34 | fseek(file, 0, SEEK_SET); 35 | fread(newFile.bytes.data(), 1, newFile.bytes.size() - 1, file); 36 | newFile.bytes[newFile.bytes.size() - 1] = 0; 37 | fclose(file); 38 | } 39 | 40 | s_cache[s] = newFile; 41 | } 42 | 43 | // return the entry for this file 44 | return s_cache[s]; 45 | } 46 | 47 | }; //namespace DX12Utils 48 | -------------------------------------------------------------------------------- /Demo/mnist/DX12Utils/FileCache.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // Machine Learning Introduction For Game Developers // 3 | // Copyright (c) 2023 Electronic Arts Inc. All rights reserved. // 4 | /////////////////////////////////////////////////////////////////////////////// 5 | 6 | #pragma once 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | namespace DX12Utils 13 | { 14 | 15 | class FileCache 16 | { 17 | public: 18 | struct File 19 | { 20 | bool Valid() 21 | { 22 | return bytes.size() > 0; 23 | } 24 | 25 | size_t GetSize() const 26 | { 27 | // Note that we add an extra null character on the end for text files, so size is really size-1 28 | size_t ret = bytes.size(); 29 | if (ret > 0) 30 | ret--; 31 | return ret; 32 | } 33 | 34 | const char* GetBytes() const 35 | { 36 | return bytes.data(); 37 | } 38 | 39 | private: 40 | friend class FileCache; 41 | 42 | // Hidden away because we add an extra character for a null terminator for text files 43 | std::vector bytes; 44 | }; 45 | 46 | static File& Get(const char* fileName); 47 | 48 | static bool Remove(const char* fileName) 49 | { 50 | if (s_cache.count(fileName) == 0) 51 | return false; 52 | 53 | s_cache.erase(fileName); 54 | return true; 55 | } 56 | 57 | static void ClearCache() 58 | { 59 | std::unordered_map empty; 60 | std::swap(s_cache, empty); 61 | } 62 | 63 | private: 64 | FileCache() {} // This is a static class 65 | 66 | private: 67 | static std::unordered_map s_cache; 68 | }; 69 | 70 | }; //namespace DX12Utils 71 | -------------------------------------------------------------------------------- /Demo/mnist/DX12Utils/SRGB.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // Machine Learning Introduction For Game Developers // 3 | // Copyright (c) 2023 Electronic Arts Inc. All rights reserved. // 4 | /////////////////////////////////////////////////////////////////////////////// 5 | 6 | #pragma once 7 | 8 | #include 9 | #include "SRGB.h" 10 | 11 | namespace DX12Utils 12 | { 13 | // adapted from https://github.com/TheRealMJP/BakingLab 14 | 15 | inline float SRGBToLinear(float color) 16 | { 17 | float x = color / 12.92f; 18 | float y = std::pow((color + 0.055f) / 1.055f, 2.4f); 19 | return color <= 0.04045f ? x : y; 20 | } 21 | 22 | inline float LinearTosRGB(float color) 23 | { 24 | float x = color * 12.92f; 25 | float y = std::pow(color, 1.0f / 2.4f) * 1.055f - 0.055f; 26 | return color < 0.0031308f ? x : y; 27 | } 28 | 29 | inline unsigned char SRGBToLinear(unsigned char color) 30 | { 31 | float f = float(color) / 255.0f; 32 | f = SRGBToLinear(f); 33 | f *= 255.0f; 34 | if (f < 0.0f) 35 | f = 0.0f; 36 | if (f > 255.0f) 37 | f = 255.0f; 38 | return (unsigned char)f; 39 | } 40 | 41 | inline unsigned char LinearTosRGB(unsigned char color) 42 | { 43 | float f = float(color) / 255.0f; 44 | f = LinearTosRGB(f); 45 | f *= 255.0f; 46 | if (f < 0.0f) 47 | f = 0.0f; 48 | if (f > 255.0f) 49 | f = 255.0f; 50 | return (unsigned char)f; 51 | } 52 | 53 | }; // namespace DX12Utils -------------------------------------------------------------------------------- /Demo/mnist/DX12Utils/TextureCache.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // Machine Learning Introduction For Game Developers // 3 | // Copyright (c) 2023 Electronic Arts Inc. All rights reserved. // 4 | /////////////////////////////////////////////////////////////////////////////// 5 | 6 | #pragma once 7 | 8 | #include 9 | #include 10 | #include 11 | #include "SRGB.h" 12 | 13 | namespace DX12Utils 14 | { 15 | 16 | class TextureCache 17 | { 18 | public: 19 | enum class Type 20 | { 21 | U8, 22 | F32 23 | }; 24 | 25 | struct Texture 26 | { 27 | bool Valid() 28 | { 29 | return pixels.size() > 0; 30 | } 31 | 32 | int SizeOfPixel() const 33 | { 34 | return channels * SizeOfChannel(); 35 | } 36 | 37 | int SizeOfChannel() const 38 | { 39 | return (type == Type::F32) ? 4 : 1; 40 | } 41 | 42 | int width = 0; 43 | int height = 0; 44 | int channels = 0; 45 | Type type = Type::U8; 46 | std::vector pixels; 47 | std::string fileName; 48 | }; 49 | 50 | static Texture& Get(const char* fileName); 51 | 52 | static Texture GetAs(const char* fileName, bool sourceIsSRGB, Type desiredType, bool desiredSRGB, int desiredChannels = 0); 53 | 54 | static bool Remove(const char* fileName) 55 | { 56 | if (s_cache.count(fileName) == 0) 57 | return false; 58 | 59 | s_cache.erase(fileName); 60 | return true; 61 | } 62 | 63 | static void ClearCache() 64 | { 65 | std::unordered_map empty; 66 | std::swap(s_cache, empty); 67 | } 68 | 69 | private: 70 | TextureCache() {} // This is a static class 71 | 72 | static Texture s_invalidTexture; 73 | 74 | private: 75 | static std::unordered_map s_cache; 76 | }; 77 | 78 | }; // namespace DX12Utils -------------------------------------------------------------------------------- /Demo/mnist/DX12Utils/logfn.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // Machine Learning Introduction For Game Developers // 3 | // Copyright (c) 2023 Electronic Arts Inc. All rights reserved. // 4 | /////////////////////////////////////////////////////////////////////////////// 5 | 6 | #pragma once 7 | 8 | enum class LogLevel : int 9 | { 10 | Info, 11 | Warn, 12 | Error 13 | }; 14 | using TLogFn = void (*)(LogLevel level, const char* msg, ...); 15 | -------------------------------------------------------------------------------- /Demo/mnist/DX12Utils/stb/LICENSE: -------------------------------------------------------------------------------- 1 | This software is available under 2 licenses -- choose whichever you prefer. 2 | ------------------------------------------------------------------------------ 3 | ALTERNATIVE A - MIT License 4 | Copyright (c) 2017 Sean Barrett 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 9 | of the Software, and to permit persons to whom the Software is furnished to do 10 | so, subject to the following conditions: 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | ------------------------------------------------------------------------------ 21 | ALTERNATIVE B - Public Domain (www.unlicense.org) 22 | This is free and unencumbered software released into the public domain. 23 | Anyone is free to copy, modify, publish, use, compile, sell, or distribute this 24 | software, either in source code form or as a compiled binary, for any purpose, 25 | commercial or non-commercial, and by any means. 26 | In jurisdictions that recognize copyright laws, the author or authors of this 27 | software dedicate any and all copyright interest in the software to the public 28 | domain. We make this dedication for the benefit of the public at large and to 29 | the detriment of our heirs and successors. We intend this dedication to be an 30 | overt act of relinquishment in perpetuity of all present and future rights to 31 | this software under copyright law. 32 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 33 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 34 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 35 | AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 36 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 37 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 38 | -------------------------------------------------------------------------------- /Demo/mnist/DX12Utils/tinyexr/deps/miniz/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2013-2014 RAD Game Tools and Valve Software 2 | Copyright 2010-2014 Rich Geldreich and Tenacious Software LLC 3 | 4 | All Rights Reserved. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /Demo/mnist/Gigi/0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronicarts/cpp-ml-intro/682222d9993d122749723b54d8d6064d6117288a/Demo/mnist/Gigi/0.png -------------------------------------------------------------------------------- /Demo/mnist/Gigi/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronicarts/cpp-ml-intro/682222d9993d122749723b54d8d6064d6117288a/Demo/mnist/Gigi/1.png -------------------------------------------------------------------------------- /Demo/mnist/Gigi/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronicarts/cpp-ml-intro/682222d9993d122749723b54d8d6064d6117288a/Demo/mnist/Gigi/2.png -------------------------------------------------------------------------------- /Demo/mnist/Gigi/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronicarts/cpp-ml-intro/682222d9993d122749723b54d8d6064d6117288a/Demo/mnist/Gigi/3.png -------------------------------------------------------------------------------- /Demo/mnist/Gigi/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronicarts/cpp-ml-intro/682222d9993d122749723b54d8d6064d6117288a/Demo/mnist/Gigi/4.png -------------------------------------------------------------------------------- /Demo/mnist/Gigi/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronicarts/cpp-ml-intro/682222d9993d122749723b54d8d6064d6117288a/Demo/mnist/Gigi/5.png -------------------------------------------------------------------------------- /Demo/mnist/Gigi/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronicarts/cpp-ml-intro/682222d9993d122749723b54d8d6064d6117288a/Demo/mnist/Gigi/6.png -------------------------------------------------------------------------------- /Demo/mnist/Gigi/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronicarts/cpp-ml-intro/682222d9993d122749723b54d8d6064d6117288a/Demo/mnist/Gigi/7.png -------------------------------------------------------------------------------- /Demo/mnist/Gigi/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronicarts/cpp-ml-intro/682222d9993d122749723b54d8d6064d6117288a/Demo/mnist/Gigi/8.png -------------------------------------------------------------------------------- /Demo/mnist/Gigi/9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronicarts/cpp-ml-intro/682222d9993d122749723b54d8d6064d6117288a/Demo/mnist/Gigi/9.png -------------------------------------------------------------------------------- /Demo/mnist/Gigi/Backprop_Weights.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronicarts/cpp-ml-intro/682222d9993d122749723b54d8d6064d6117288a/Demo/mnist/Gigi/Backprop_Weights.bin -------------------------------------------------------------------------------- /Demo/mnist/Gigi/CalculateExtents.hlsl: -------------------------------------------------------------------------------- 1 | /*$(ShaderResources)*/ 2 | 3 | /*$(_compute:CalculateExtents)*/(uint3 DTid : SV_DispatchThreadID) 4 | { 5 | if (Canvas[DTid.xy] == 0.0f) 6 | return; 7 | 8 | uint dummy = 0; 9 | InterlockedMin(DrawExtents[0].MinX, DTid.x, dummy); 10 | InterlockedMax(DrawExtents[0].MaxX, DTid.x, dummy); 11 | InterlockedMin(DrawExtents[0].MinY, DTid.y, dummy); 12 | InterlockedMax(DrawExtents[0].MaxY, DTid.y, dummy); 13 | 14 | InterlockedAdd(DrawExtents[0].PixelCount, 1, dummy); 15 | InterlockedAdd(DrawExtents[0].PixelLocationSum.x, DTid.x, dummy); 16 | InterlockedAdd(DrawExtents[0].PixelLocationSum.y, DTid.y, dummy); 17 | } -------------------------------------------------------------------------------- /Demo/mnist/Gigi/HiddenLayer.hlsl: -------------------------------------------------------------------------------- 1 | /*$(ShaderResources)*/ 2 | 3 | /*$(_compute:HiddenLayer)*/(uint3 DTid : SV_DispatchThreadID) 4 | { 5 | int hiddenNeuronIndex = DTid.x; 6 | 7 | // Calculate where the weights begin and end for this neuron. 8 | // There is an extra weight for the bias 9 | int weightsBeginIndex = hiddenNeuronIndex * (/*$(Variable:c_numInputNeurons)*/ + 1); 10 | 11 | const uint2 inputResolution = uint2/*$(Variable:c_NNInputImageSize)*/; 12 | 13 | float output = NNWeights[weightsBeginIndex + int/*$(Variable:c_numInputNeurons)*/]; // bias 14 | for (int inputNeuronIndex = 0; inputNeuronIndex < int/*$(Variable:c_numInputNeurons)*/; ++inputNeuronIndex) 15 | { 16 | uint2 inputPixelPos = uint2(inputNeuronIndex % inputResolution.x, inputNeuronIndex / inputResolution.x ); 17 | output += NNInput[inputPixelPos] * NNWeights[weightsBeginIndex + inputNeuronIndex]; 18 | } 19 | 20 | // activation function 21 | HiddenLayerActivations[hiddenNeuronIndex] = 1.0f / (1.0f + exp(-output)); 22 | } -------------------------------------------------------------------------------- /Demo/mnist/Gigi/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2023 Electronic Arts Inc. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 4 | 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 7 | 3. Neither the name of Electronic Arts, Inc. ("EA") nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 8 | 4. EA’s marks or logos, including SEED logos, are distributed with this software solely for demonstration purposes and may not be displayed or shared other than as part of a redistribution of this software, provided they are redistributed without modification. No other rights are provided for the use of these marks and logos, other than for their intended demonstration purposes. 9 | 10 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 11 | -------------------------------------------------------------------------------- /Demo/mnist/Gigi/OutputLayer.hlsl: -------------------------------------------------------------------------------- 1 | /*$(ShaderResources)*/ 2 | 3 | /*$(_compute:OutputLayer)*/(uint3 DTid : SV_DispatchThreadID) 4 | { 5 | int outputNeuronIndex = DTid.x; 6 | 7 | // Calculate where the weights begin and end for this neuron. 8 | // There is an extra weight for the bias 9 | int weightsBeginIndex = /*$(Variable:c_numHiddenWeights)*/ + outputNeuronIndex * (/*$(Variable:c_numHiddenNeurons)*/ + 1); 10 | 11 | float output = NNWeights[weightsBeginIndex + int/*$(Variable:c_numHiddenNeurons)*/]; // bias 12 | for (int hiddenNeuronIndex = 0; hiddenNeuronIndex < int/*$(Variable:c_numHiddenNeurons)*/; ++hiddenNeuronIndex) 13 | output += HiddenLayerActivations[hiddenNeuronIndex] * NNWeights[weightsBeginIndex + hiddenNeuronIndex]; 14 | 15 | // activation function 16 | OutputLayerActivations[outputNeuronIndex] = 1.0f / (1.0f + exp(-output)); 17 | } 18 | -------------------------------------------------------------------------------- /Demo/mnist/Gigi/Screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronicarts/cpp-ml-intro/682222d9993d122749723b54d8d6064d6117288a/Demo/mnist/Gigi/Screenshot.png -------------------------------------------------------------------------------- /Demo/mnist/Gigi/Technique.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title":"Machina2023", 3 | "Description":"Recognizes what number you draw. Machine learning inference in compute shaders. Part of a tutorial on machine learning in C++ for game developers.", 4 | "Author":"Demofox", 5 | "Tags":"ML,inference", 6 | "Technique": "mnist.gg", 7 | "Website": "https://github.com/electronicarts/cpp-ml-intro", 8 | "Screenshot":"Screenshot.png", 9 | "License":"LICENSE.txt", 10 | "GigiVersion":"0.99b", 11 | } -------------------------------------------------------------------------------- /Demo/mnist/Gigi/draw.hlsl: -------------------------------------------------------------------------------- 1 | /*$(ShaderResources)*/ 2 | 3 | /*$(_compute:Draw)*/(uint3 DTid : SV_DispatchThreadID) 4 | { 5 | if (DTid.x == 0 && DTid.y == 0) 6 | { 7 | uint2 canvasSize = uint2/*$(Variable:c_drawingCanvasSize)*/; 8 | DrawExtents[0].MinX = canvasSize.x; 9 | DrawExtents[0].MinY = canvasSize.y; 10 | DrawExtents[0].MaxX = 0; 11 | DrawExtents[0].MaxY = 0; 12 | DrawExtents[0].PixelCount = 0; 13 | DrawExtents[0].PixelLocationSum = uint2(0, 0); 14 | } 15 | 16 | if (/*$(Variable:Clear)*/ != 0 || /*$(Variable:iFrame)*/ == 0) 17 | { 18 | Canvas[DTid.xy] = 0.0f; 19 | return; 20 | } 21 | 22 | // Don't allow drawing when the user isn't looking at the drawing canvas 23 | if (/*$(Variable:UseImportedImage)*/) 24 | return; 25 | 26 | float4 mouseLastFrame = /*$(Variable:MouseStateLastFrame)*/; 27 | float4 mouse = /*$(Variable:MouseState)*/; 28 | 29 | // This is to compensate for us drawing it at 30,30 in the presentation pass 30 | mouseLastFrame.xy -= 30.0f; 31 | mouse.xy -= 30.0f; 32 | 33 | // If the mouse moved, and was pressed last frame and this frame, draw a line 34 | // between the mouse positions 35 | if (((mouseLastFrame.z != 0.0f && mouse.z != 0.0f) || (mouseLastFrame.w != 0.0f && mouse.w != 0.0f)) && (mouseLastFrame.x != mouse.x || mouseLastFrame.y != mouse.y)) 36 | { 37 | // Get distance from pixel to line 38 | // Color the pixel in, if it's close enough 39 | 40 | // Get a normalized vector from A to B 41 | float2 A = mouseLastFrame.xy; 42 | float2 B = mouse.xy; 43 | float2 AB = normalize(B - A); 44 | 45 | // Project the pixel onto it 46 | float t = dot(AB, float2(DTid.xy) - A); 47 | 48 | // Get the closest point on the line to the pixel 49 | t = clamp(t, 0.0f, length(B-A)); 50 | float2 closestPoint = A + AB * t; 51 | 52 | // color the pixel if it's close enough. 53 | // Draw a 1 if the left mouse is down. Draw a 0 if the right mouse is down. 54 | float2 closestPointToPixel = float2(DTid.xy) - closestPoint; 55 | if (dot(closestPointToPixel, closestPointToPixel) < (/*$(Variable:PenSize)*/ * /*$(Variable:PenSize)*/)) 56 | Canvas[DTid.xy] = mouse.z; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Demo/mnist/Gigi/instructions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronicarts/cpp-ml-intro/682222d9993d122749723b54d8d6064d6117288a/Demo/mnist/Gigi/instructions.png -------------------------------------------------------------------------------- /Demo/mnist/Gigi/mnist.gguser: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0", 3 | "systemVars": { 4 | "iResolution_textureName": "Drawing_Canvas", 5 | "iFrame_varName": "" 6 | }, 7 | "snapshot": { 8 | "resourceViewNodeIndex": 9, 9 | "resourceViewResourceIndex": 17, 10 | "importedResources": [ 11 | { 12 | "nodeName": "Imported_Image", 13 | "texture": { 14 | "fileName": "9.png", 15 | "size": [ 16 | 28, 17 | 28, 18 | 1 19 | ], 20 | "format": "R8_Unorm" 21 | } 22 | }, 23 | { 24 | "nodeName": "NN_Weights", 25 | "resetEveryFrame": false, 26 | "isATexture": false, 27 | "buffer": { 28 | "fileName": "Backprop_Weights.bin", 29 | "type": "Float" 30 | } 31 | }, 32 | { 33 | "nodeName": "Presentation_Canvas", 34 | "texture": { 35 | "size": [ 36 | 480, 37 | 990, 38 | 1 39 | ], 40 | "format": "RGBA8_Unorm" 41 | } 42 | } 43 | ], 44 | "savedVariables": [ 45 | { 46 | "name": "Clear", 47 | "value": "false" 48 | }, 49 | { 50 | "name": "PenSize", 51 | "value": "10.000000" 52 | }, 53 | { 54 | "name": "UseImportedImage", 55 | "value": "false" 56 | }, 57 | { 58 | "name": "NormalizeDrawing", 59 | "value": "true" 60 | } 61 | ] 62 | } 63 | } -------------------------------------------------------------------------------- /Demo/mnist/assets/0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronicarts/cpp-ml-intro/682222d9993d122749723b54d8d6064d6117288a/Demo/mnist/assets/0.png -------------------------------------------------------------------------------- /Demo/mnist/assets/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronicarts/cpp-ml-intro/682222d9993d122749723b54d8d6064d6117288a/Demo/mnist/assets/1.png -------------------------------------------------------------------------------- /Demo/mnist/assets/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronicarts/cpp-ml-intro/682222d9993d122749723b54d8d6064d6117288a/Demo/mnist/assets/2.png -------------------------------------------------------------------------------- /Demo/mnist/assets/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronicarts/cpp-ml-intro/682222d9993d122749723b54d8d6064d6117288a/Demo/mnist/assets/3.png -------------------------------------------------------------------------------- /Demo/mnist/assets/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronicarts/cpp-ml-intro/682222d9993d122749723b54d8d6064d6117288a/Demo/mnist/assets/4.png -------------------------------------------------------------------------------- /Demo/mnist/assets/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronicarts/cpp-ml-intro/682222d9993d122749723b54d8d6064d6117288a/Demo/mnist/assets/5.png -------------------------------------------------------------------------------- /Demo/mnist/assets/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronicarts/cpp-ml-intro/682222d9993d122749723b54d8d6064d6117288a/Demo/mnist/assets/6.png -------------------------------------------------------------------------------- /Demo/mnist/assets/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronicarts/cpp-ml-intro/682222d9993d122749723b54d8d6064d6117288a/Demo/mnist/assets/7.png -------------------------------------------------------------------------------- /Demo/mnist/assets/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronicarts/cpp-ml-intro/682222d9993d122749723b54d8d6064d6117288a/Demo/mnist/assets/8.png -------------------------------------------------------------------------------- /Demo/mnist/assets/9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronicarts/cpp-ml-intro/682222d9993d122749723b54d8d6064d6117288a/Demo/mnist/assets/9.png -------------------------------------------------------------------------------- /Demo/mnist/assets/Backprop_Weights.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronicarts/cpp-ml-intro/682222d9993d122749723b54d8d6064d6117288a/Demo/mnist/assets/Backprop_Weights.bin -------------------------------------------------------------------------------- /Demo/mnist/assets/instructions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronicarts/cpp-ml-intro/682222d9993d122749723b54d8d6064d6117288a/Demo/mnist/assets/instructions.png -------------------------------------------------------------------------------- /Demo/mnist/public/all.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "./technique.h" 4 | #include "./imgui.h" 5 | #include "./pythoninterface.h" 6 | -------------------------------------------------------------------------------- /Demo/mnist/public/imgui.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // Machine Learning Introduction For Game Developers // 3 | // Copyright (c) 2023 Electronic Arts Inc. All rights reserved. // 4 | /////////////////////////////////////////////////////////////////////////////// 5 | 6 | #pragma once 7 | 8 | #include "technique.h" 9 | 10 | namespace mnist 11 | { 12 | inline void ShowToolTip(const char* tooltip) 13 | { 14 | if (!tooltip || !tooltip[0]) 15 | return; 16 | 17 | ImGui::SameLine(); 18 | ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(255, 255, 0, 255)); 19 | ImGui::Text("[?]"); 20 | ImGui::PopStyleColor(); 21 | if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled)) 22 | ImGui::SetTooltip("%s", tooltip); 23 | } 24 | 25 | void MakeUI(Context* context, ID3D12CommandQueue* commandQueue) 26 | { 27 | ImGui::PushID("gigi_mnist"); 28 | 29 | context->m_input.variable_Clear = ImGui::Button("Clear"); 30 | ShowToolTip(""); 31 | ImGui::InputFloat("PenSize", &context->m_input.variable_PenSize); 32 | ShowToolTip(""); 33 | ImGui::Checkbox("UseImportedImage", &context->m_input.variable_UseImportedImage); 34 | ShowToolTip(""); 35 | ImGui::Checkbox("NormalizeDrawing", &context->m_input.variable_NormalizeDrawing); 36 | ShowToolTip("MNIST normalization: shrink image to 20x20 and put center of mass in the middle of a 28x28 image"); 37 | 38 | ImGui::Checkbox("Profile", &context->m_profile); 39 | if (context->m_profile) 40 | { 41 | int numEntries = 0; 42 | const ProfileEntry* entries = context->ReadbackProfileData(commandQueue, numEntries); 43 | if (ImGui::BeginTable("profiling", 3, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg)) 44 | { 45 | ImGui::TableSetupColumn("Label"); 46 | ImGui::TableSetupColumn("CPU ms"); 47 | ImGui::TableSetupColumn("GPU ms"); 48 | ImGui::TableHeadersRow(); 49 | float totalCpu = 0.0f; 50 | float totalGpu = 0.0f; 51 | for (int entryIndex = 0; entryIndex < numEntries; ++entryIndex) 52 | { 53 | ImGui::TableNextRow(); 54 | ImGui::TableNextColumn(); 55 | ImGui::TextUnformatted(entries[entryIndex].m_label); 56 | ImGui::TableNextColumn(); 57 | ImGui::Text("%0.3f", entries[entryIndex].m_cpu * 1000.0f); 58 | ImGui::TableNextColumn(); 59 | ImGui::Text("%0.3f", entries[entryIndex].m_gpu * 1000.0f); 60 | totalCpu += entries[entryIndex].m_cpu; 61 | totalGpu += entries[entryIndex].m_gpu; 62 | } 63 | ImGui::EndTable(); 64 | } 65 | } 66 | 67 | ImGui::PopID(); 68 | } 69 | }; 70 | -------------------------------------------------------------------------------- /Demo/mnist/shaders/CalculateExtents.hlsl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // Machine Learning Introduction For Game Developers // 3 | // Copyright (c) 2023 Electronic Arts Inc. All rights reserved. // 4 | /////////////////////////////////////////////////////////////////////////////// 5 | 6 | struct Struct_DrawExtents 7 | { 8 | uint MinX; 9 | uint MaxX; 10 | uint MinY; 11 | uint MaxY; 12 | uint PixelCount; 13 | uint2 PixelLocationSum; 14 | }; 15 | 16 | Texture2D Canvas : register(t0); 17 | RWStructuredBuffer DrawExtents : register(u0); 18 | 19 | #line 1 20 | 21 | 22 | [numthreads(8, 8, 1)] 23 | #line 3 24 | void CalculateExtents(uint3 DTid : SV_DispatchThreadID) 25 | { 26 | if (Canvas[DTid.xy] == 0.0f) 27 | return; 28 | 29 | uint dummy = 0; 30 | InterlockedMin(DrawExtents[0].MinX, DTid.x, dummy); 31 | InterlockedMax(DrawExtents[0].MaxX, DTid.x, dummy); 32 | InterlockedMin(DrawExtents[0].MinY, DTid.y, dummy); 33 | InterlockedMax(DrawExtents[0].MaxY, DTid.y, dummy); 34 | 35 | InterlockedAdd(DrawExtents[0].PixelCount, 1, dummy); 36 | InterlockedAdd(DrawExtents[0].PixelLocationSum.x, DTid.x, dummy); 37 | InterlockedAdd(DrawExtents[0].PixelLocationSum.y, DTid.y, dummy); 38 | } -------------------------------------------------------------------------------- /Demo/mnist/shaders/HiddenLayer.hlsl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // Machine Learning Introduction For Game Developers // 3 | // Copyright (c) 2023 Electronic Arts Inc. All rights reserved. // 4 | /////////////////////////////////////////////////////////////////////////////// 5 | 6 | Texture2D NNInput : register(t0); 7 | Buffer NNWeights : register(t1); 8 | RWBuffer HiddenLayerActivations : register(u0); 9 | 10 | #line 1 11 | 12 | 13 | [numthreads(64, 1, 1)] 14 | #line 3 15 | void HiddenLayer(uint3 DTid : SV_DispatchThreadID) 16 | { 17 | int hiddenNeuronIndex = DTid.x; 18 | 19 | // Calculate where the weights begin and end for this neuron. 20 | // There is an extra weight for the bias 21 | int weightsBeginIndex = hiddenNeuronIndex * ((784) + 1); 22 | 23 | const uint2 inputResolution = uint2(28, 28); 24 | 25 | float output = NNWeights[weightsBeginIndex + int(784)]; // bias 26 | for (int inputNeuronIndex = 0; inputNeuronIndex < int(784); ++inputNeuronIndex) 27 | { 28 | uint2 inputPixelPos = uint2(inputNeuronIndex % inputResolution.x, inputNeuronIndex / inputResolution.x ); 29 | output += NNInput[inputPixelPos] * NNWeights[weightsBeginIndex + inputNeuronIndex]; 30 | } 31 | 32 | // activation function 33 | HiddenLayerActivations[hiddenNeuronIndex] = 1.0f / (1.0f + exp(-output)); 34 | } -------------------------------------------------------------------------------- /Demo/mnist/shaders/OutputLayer.hlsl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // Machine Learning Introduction For Game Developers // 3 | // Copyright (c) 2023 Electronic Arts Inc. All rights reserved. // 4 | /////////////////////////////////////////////////////////////////////////////// 5 | 6 | Buffer NNWeights : register(t0); 7 | Buffer HiddenLayerActivations : register(t1); 8 | RWBuffer OutputLayerActivations : register(u0); 9 | 10 | #line 1 11 | 12 | 13 | [numthreads(64, 1, 1)] 14 | #line 3 15 | void OutputLayer(uint3 DTid : SV_DispatchThreadID) 16 | { 17 | int outputNeuronIndex = DTid.x; 18 | 19 | // Calculate where the weights begin and end for this neuron. 20 | // There is an extra weight for the bias 21 | int weightsBeginIndex = (23550) + outputNeuronIndex * ((30) + 1); 22 | 23 | float output = NNWeights[weightsBeginIndex + int(30)]; // bias 24 | for (int hiddenNeuronIndex = 0; hiddenNeuronIndex < int(30); ++hiddenNeuronIndex) 25 | output += HiddenLayerActivations[hiddenNeuronIndex] * NNWeights[weightsBeginIndex + hiddenNeuronIndex]; 26 | 27 | // activation function 28 | OutputLayerActivations[outputNeuronIndex] = 1.0f / (1.0f + exp(-output)); 29 | } 30 | -------------------------------------------------------------------------------- /Exercises/1_LogicGates/Exercise Set 1 - Instructions.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronicarts/cpp-ml-intro/682222d9993d122749723b54d8d6064d6117288a/Exercises/1_LogicGates/Exercise Set 1 - Instructions.docx -------------------------------------------------------------------------------- /Exercises/1_LogicGates/Exercise Set 1 - Solutions.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronicarts/cpp-ml-intro/682222d9993d122749723b54d8d6064d6117288a/Exercises/1_LogicGates/Exercise Set 1 - Solutions.docx -------------------------------------------------------------------------------- /Exercises/2_FiniteDifferences/Exercise Set 2 - Instructions.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronicarts/cpp-ml-intro/682222d9993d122749723b54d8d6064d6117288a/Exercises/2_FiniteDifferences/Exercise Set 2 - Instructions.docx -------------------------------------------------------------------------------- /Exercises/2_FiniteDifferences/Exercise Set 2 - Solutions.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronicarts/cpp-ml-intro/682222d9993d122749723b54d8d6064d6117288a/Exercises/2_FiniteDifferences/Exercise Set 2 - Solutions.docx -------------------------------------------------------------------------------- /Exercises/2_FiniteDifferences/FiniteDifferences/FiniteDifferences.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.5.33530.505 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FiniteDifferences", "FiniteDifferences.vcxproj", "{2B09CA28-3364-44C2-99DD-C4C4B0FC5E13}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {2B09CA28-3364-44C2-99DD-C4C4B0FC5E13}.Debug|x64.ActiveCfg = Debug|x64 17 | {2B09CA28-3364-44C2-99DD-C4C4B0FC5E13}.Debug|x64.Build.0 = Debug|x64 18 | {2B09CA28-3364-44C2-99DD-C4C4B0FC5E13}.Debug|x86.ActiveCfg = Debug|Win32 19 | {2B09CA28-3364-44C2-99DD-C4C4B0FC5E13}.Debug|x86.Build.0 = Debug|Win32 20 | {2B09CA28-3364-44C2-99DD-C4C4B0FC5E13}.Release|x64.ActiveCfg = Release|x64 21 | {2B09CA28-3364-44C2-99DD-C4C4B0FC5E13}.Release|x64.Build.0 = Release|x64 22 | {2B09CA28-3364-44C2-99DD-C4C4B0FC5E13}.Release|x86.ActiveCfg = Release|Win32 23 | {2B09CA28-3364-44C2-99DD-C4C4B0FC5E13}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {ACC2A53D-47EC-460A-A2FA-C968DB350A54} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /Exercises/2_FiniteDifferences/FiniteDifferences/FiniteDifferences.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Exercises/2_FiniteDifferences/FiniteDifferences/FiniteDifferences.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Exercises/2_FiniteDifferences/FiniteDifferences/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | static const int c_numSteps = 50; 5 | static const bool c_deterministic = false; // Set to true to get the same random numbers every run. useful for debugging 6 | static const float c_gradientStepSize = 0.1f; 7 | 8 | float F(float x) 9 | { 10 | // y = (x+1)^2-2 11 | // The minimum is at x=-1, with a y value of -2 12 | return (x + 1.0f) * (x + 1.0f) - 2.0f; 13 | } 14 | 15 | float FDerivative(float x) 16 | { 17 | // TODO: implement finite difference to return the derivative of function F(), at location x. 18 | } 19 | 20 | std::mt19937 GetRNG() 21 | { 22 | if (c_deterministic) 23 | { 24 | std::mt19937 rng; 25 | return rng; 26 | } 27 | else 28 | { 29 | std::random_device rd; 30 | std::mt19937 rng(rd()); 31 | return rng; 32 | } 33 | } 34 | 35 | int main(int argc, char** argv) 36 | { 37 | std::mt19937 rng = GetRNG(); 38 | std::uniform_real_distribution dist(-10.0f, 10.0f); 39 | 40 | float x = dist(rng); 41 | 42 | int lastPercent = -1; 43 | for (int i = 0; i < c_numSteps; ++i) 44 | { 45 | float derivative = FDerivative(x); 46 | 47 | int percent = int(100.0f * float(i) / float(c_numSteps - 1)); 48 | if (percent != lastPercent) 49 | { 50 | printf("%3i%%: x = %0.2f, y = %0.2f, y' = %0.2f\n", percent, x, F(x), derivative); 51 | lastPercent = percent; 52 | } 53 | 54 | x -= derivative * c_gradientStepSize; 55 | } 56 | 57 | return 0; 58 | } -------------------------------------------------------------------------------- /Exercises/3_DualNumbers/DualNumbers/DualNumbers.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.5.33530.505 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DualNumbers", "DualNumbers.vcxproj", "{69398498-45E8-4A67-92DA-D97A749F171A}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {69398498-45E8-4A67-92DA-D97A749F171A}.Debug|x64.ActiveCfg = Debug|x64 17 | {69398498-45E8-4A67-92DA-D97A749F171A}.Debug|x64.Build.0 = Debug|x64 18 | {69398498-45E8-4A67-92DA-D97A749F171A}.Debug|x86.ActiveCfg = Debug|Win32 19 | {69398498-45E8-4A67-92DA-D97A749F171A}.Debug|x86.Build.0 = Debug|Win32 20 | {69398498-45E8-4A67-92DA-D97A749F171A}.Release|x64.ActiveCfg = Release|x64 21 | {69398498-45E8-4A67-92DA-D97A749F171A}.Release|x64.Build.0 = Release|x64 22 | {69398498-45E8-4A67-92DA-D97A749F171A}.Release|x86.ActiveCfg = Release|Win32 23 | {69398498-45E8-4A67-92DA-D97A749F171A}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {3AA0DF83-3AE3-4C64-846A-6DF077AB939A} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /Exercises/3_DualNumbers/DualNumbers/DualNumbers.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Exercises/3_DualNumbers/DualNumbers/DualNumbers.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Exercises/3_DualNumbers/DualNumbers/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | static const int c_numSteps = 50; 5 | static const bool c_deterministic = false; // Set to true to get the same random numbers every run. useful for debugging 6 | static const float c_gradientStepSize = 0.1f; 7 | 8 | struct CDualNumber 9 | { 10 | CDualNumber() 11 | { 12 | 13 | } 14 | 15 | // Conversion from floating point constant to dual number 16 | CDualNumber(float f) 17 | : m_real(f) 18 | , m_dual(0.0f) 19 | { 20 | } 21 | 22 | CDualNumber(float real, float dual) 23 | : m_real(real) 24 | , m_dual(dual) 25 | { 26 | } 27 | 28 | float m_real = 0.0f; // The value 29 | float m_dual = 0.0f; // The derivative. Constant values will always have a derivative / dual value of 0. 30 | float m_dualX = 0.0f; 31 | float m_dualY = 0.0f; 32 | 33 | // TODO: implement these operators to make the program run 34 | 35 | CDualNumber operator+(const CDualNumber& d) 36 | { 37 | 38 | } 39 | 40 | CDualNumber operator-(const CDualNumber& d) 41 | { 42 | 43 | } 44 | 45 | CDualNumber operator*(const CDualNumber& d) 46 | { 47 | 48 | } 49 | }; 50 | 51 | template 52 | T F(T x) 53 | { 54 | // y = (x+1)^2-2 55 | // The minimum is at x=-1, with a y value of -2 56 | return (x + 1.0f) * (x + 1.0f) - 2.0f; 57 | } 58 | 59 | float FDerivative(float x) 60 | { 61 | // Calculate the derivative by making a dual number and putting it through the F() function 62 | CDualNumber dualX(x, 1.0f); 63 | return F(dualX).m_dual; 64 | } 65 | 66 | std::mt19937 GetRNG() 67 | { 68 | if (c_deterministic) 69 | { 70 | std::mt19937 rng; 71 | return rng; 72 | } 73 | else 74 | { 75 | std::random_device rd; 76 | std::mt19937 rng(rd()); 77 | return rng; 78 | } 79 | } 80 | 81 | int main(int argc, char** argv) 82 | { 83 | std::mt19937 rng = GetRNG(); 84 | std::uniform_real_distribution dist(-10.0f, 10.0f); 85 | 86 | float x = dist(rng); 87 | 88 | int lastPercent = -1; 89 | for (int i = 0; i < c_numSteps; ++i) 90 | { 91 | float derivative = FDerivative(x); 92 | 93 | int percent = int(100.0f * float(i) / float(c_numSteps - 1)); 94 | if (percent != lastPercent) 95 | { 96 | printf("%3i%%: x = %0.2f, y = %0.2f, y' = %0.2f\n", percent, x, F(x), derivative); 97 | lastPercent = percent; 98 | } 99 | 100 | x -= derivative * c_gradientStepSize; 101 | } 102 | 103 | return 0; 104 | } 105 | -------------------------------------------------------------------------------- /Exercises/3_DualNumbers/Exercise Set 3 - Instructions.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronicarts/cpp-ml-intro/682222d9993d122749723b54d8d6064d6117288a/Exercises/3_DualNumbers/Exercise Set 3 - Instructions.docx -------------------------------------------------------------------------------- /Exercises/3_DualNumbers/Exercise Set 3 - Solutions.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronicarts/cpp-ml-intro/682222d9993d122749723b54d8d6064d6117288a/Exercises/3_DualNumbers/Exercise Set 3 - Solutions.docx -------------------------------------------------------------------------------- /Exercises/4_Backprop/ChainRule/ChainRule.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.5.33530.505 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ChainRule", "ChainRule.vcxproj", "{F1EA3BE3-D328-402F-B074-B14AF2265C92}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {F1EA3BE3-D328-402F-B074-B14AF2265C92}.Debug|x64.ActiveCfg = Debug|x64 17 | {F1EA3BE3-D328-402F-B074-B14AF2265C92}.Debug|x64.Build.0 = Debug|x64 18 | {F1EA3BE3-D328-402F-B074-B14AF2265C92}.Debug|x86.ActiveCfg = Debug|Win32 19 | {F1EA3BE3-D328-402F-B074-B14AF2265C92}.Debug|x86.Build.0 = Debug|Win32 20 | {F1EA3BE3-D328-402F-B074-B14AF2265C92}.Release|x64.ActiveCfg = Release|x64 21 | {F1EA3BE3-D328-402F-B074-B14AF2265C92}.Release|x64.Build.0 = Release|x64 22 | {F1EA3BE3-D328-402F-B074-B14AF2265C92}.Release|x86.ActiveCfg = Release|Win32 23 | {F1EA3BE3-D328-402F-B074-B14AF2265C92}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {F135DB65-0BE3-41FE-A5F2-C4EB4E7B5A25} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /Exercises/4_Backprop/ChainRule/ChainRule.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Exercises/4_Backprop/ChainRule/ChainRule.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Exercises/4_Backprop/ChainRule/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | static const int c_numSteps = 50; 5 | static const bool c_deterministic = false; // Set to true to get the same random numbers every run. useful for debugging 6 | static const float c_gradientStepSize = 0.1f; 7 | 8 | float G(float x) 9 | { 10 | return x * x; 11 | } 12 | 13 | float GDerivative(float x) 14 | { 15 | return 2.0f * x; 16 | } 17 | 18 | float H(float x) 19 | { 20 | return 3.0f * x + 5.0f; 21 | } 22 | 23 | float HDerivative(float x) 24 | { 25 | return 3.0f; 26 | } 27 | 28 | float I(float x) 29 | { 30 | return x * 0.9f + 5.0f; 31 | } 32 | 33 | float IDerivative(float x) 34 | { 35 | return 0.9f; 36 | } 37 | 38 | float F(float x) 39 | { 40 | return G(H(I(x))); 41 | } 42 | 43 | float FDerivative(float x) 44 | { 45 | // TODO: calculate the derivative of F using the chain rule 46 | } 47 | 48 | std::mt19937 GetRNG() 49 | { 50 | if (c_deterministic) 51 | { 52 | std::mt19937 rng; 53 | return rng; 54 | } 55 | else 56 | { 57 | std::random_device rd; 58 | std::mt19937 rng(rd()); 59 | return rng; 60 | } 61 | } 62 | 63 | int main(int argc, char** argv) 64 | { 65 | std::mt19937 rng = GetRNG(); 66 | std::uniform_real_distribution dist(-10.0f, 10.0f); 67 | 68 | float x = dist(rng); 69 | 70 | int lastPercent = -1; 71 | for (int i = 0; i < c_numSteps; ++i) 72 | { 73 | float derivative = FDerivative(x); 74 | 75 | int percent = int(100.0f * float(i) / float(c_numSteps - 1)); 76 | if (percent != lastPercent) 77 | { 78 | printf("%3i%%: x = %0.2f, y = %0.2f, y' = %0.2f\n", percent, x, F(x), derivative); 79 | lastPercent = percent; 80 | } 81 | 82 | x -= derivative * c_gradientStepSize; 83 | } 84 | 85 | return 0; 86 | } 87 | -------------------------------------------------------------------------------- /Exercises/4_Backprop/Exercise Set 4 - Instructions.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronicarts/cpp-ml-intro/682222d9993d122749723b54d8d6064d6117288a/Exercises/4_Backprop/Exercise Set 4 - Instructions.docx -------------------------------------------------------------------------------- /Exercises/4_Backprop/Exercise Set 4 - Solutions.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronicarts/cpp-ml-intro/682222d9993d122749723b54d8d6064d6117288a/Exercises/4_Backprop/Exercise Set 4 - Solutions.docx -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2023 Electronic Arts Inc. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 4 | 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 7 | 3. Neither the name of Electronic Arts, Inc. ("EA") nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 8 | 4. EA’s marks or logos, including SEED logos, are distributed with this software solely for demonstration purposes and may not be displayed or shared other than as part of a redistribution of this software, provided they are redistributed without modification. No other rights are provided for the use of these marks and logos, other than for their intended demonstration purposes. 9 | 10 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 11 | -------------------------------------------------------------------------------- /Machina Presentation 2023 - ML Intro For Game Devs.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronicarts/cpp-ml-intro/682222d9993d122749723b54d8d6064d6117288a/Machina Presentation 2023 - ML Intro For Game Devs.pptx -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CPPMLBasics 2 | 3 | The code repo to go with the blog posts and YouTube video: 4 | 1. Blog Part I: https://www.ea.com/seed/news/machine-learning-game-devs-part-1 5 | 2. Blog Part II: https://www.ea.com/seed/news/machine-learning-game-devs-part-2 6 | 3. Blog Part III: https://www.ea.com/seed/news/machine-learning-game-devs-part-3 7 | 4. All 3 parts in one video: https://www.youtube.com/watch?v=sTAqWRsEiy0 8 | 9 | The `Data` folder contains the mnist hand drawn digits in their source format. Executing the `Training` project will extract those images into pngs. 10 | 11 | The `Demo` folder contains the C++ DX12 demo which allows you to draw numbers, and have the neural network run on the GPU to try and classify what number you drew. 12 | 13 | The `Training` folder contains the C++ code to train the neural network on the mnist data. 14 | 15 | The `Exercises` folder contains the exercises that go along with the article. 16 | 17 | ## Authors 18 | 19 |


20 | Search for Extraordinary Experiences Division (SEED) - Electronic Arts
http://seed.ea.com

21 | We are a cross-disciplinary team within EA Worldwide Studios.
22 | Our mission is to explore, build and help define the future of interactive entertainment.

23 | 24 | This code accompanies articles written by Alan Wolfe (blog.demofox.org) 25 | -------------------------------------------------------------------------------- /Training/DataSet.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // Machine Learning Introduction For Game Developers // 3 | // Copyright (c) 2023 Electronic Arts Inc. All rights reserved. // 4 | /////////////////////////////////////////////////////////////////////////////// 5 | 6 | #pragma once 7 | 8 | #include 9 | #include 10 | #include "Settings.h" 11 | #include 12 | 13 | struct DataItem 14 | { 15 | int label; 16 | float image[c_imageDims * c_imageDims + 1]; // We have an extra 1.0 value for the input layer bias term 17 | }; 18 | 19 | typedef std::vector DataSet; 20 | 21 | void ExtractMNISTData(DataSet& trainingData, DataSet& testingData); -------------------------------------------------------------------------------- /Training/GetGradient_BackProp.cpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // Machine Learning Introduction For Game Developers // 3 | // Copyright (c) 2023 Electronic Arts Inc. All rights reserved. // 4 | /////////////////////////////////////////////////////////////////////////////// 5 | 6 | #include "Settings.h" 7 | #include "DataSet.h" 8 | 9 | std::span GetGradient_Backprop(TNeuralNetwork& neuralNet, const DataItem& dataItem) 10 | { 11 | return neuralNet.ForwardPassAndBackprop(dataItem.image, dataItem.label); 12 | } -------------------------------------------------------------------------------- /Training/GetGradient_DualNumbers.cpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // Machine Learning Introduction For Game Developers // 3 | // Copyright (c) 2023 Electronic Arts Inc. All rights reserved. // 4 | /////////////////////////////////////////////////////////////////////////////// 5 | 6 | #include "Settings.h" 7 | #include "DataSet.h" 8 | 9 | std::span GetGradient_DualNumbers(TNeuralNetwork& neuralNet, const DataItem& dataItem) 10 | { 11 | static std::vector gradient(TNeuralNetwork::c_numWeights); 12 | 13 | // Evaluate it and get the cost as a dual number 14 | DualNumber cost = neuralNet.EvaluateOneHotCost(dataItem.image, dataItem.label); 15 | 16 | // extract the gradient 17 | for (int i = 0; i < gradient.size(); ++i) 18 | gradient[i] = -cost.GetDualValue(i); 19 | 20 | return std::span{ gradient.data(), TNeuralNetwork::c_numWeights }; 21 | } 22 | -------------------------------------------------------------------------------- /Training/Settings.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // Machine Learning Introduction For Game Developers // 3 | // Copyright (c) 2023 Electronic Arts Inc. All rights reserved. // 4 | /////////////////////////////////////////////////////////////////////////////// 5 | 6 | #pragma once 7 | 8 | #include "NN.h" 9 | 10 | #define TRAIN_FORWARD_DIFF() false 11 | #define TRAIN_CENTRAL_DIFF() false 12 | #define TRAIN_DUAL_NUMBERS() false 13 | #define TRAIN_BACKPROP() true 14 | 15 | #define DETERMINISTIC() false 16 | #define MULTI_THREADED() true 17 | 18 | static const size_t c_imageDims = 28; 19 | 20 | const size_t c_trainingEpochs = 30; // How many times we go through all of the training data. 21 | const size_t c_miniBatchSize = 10; // How many items of the training data we should train against, at a time. 22 | const float c_learningRate = 3.0f; // How fast should we travel down the gradient. 23 | 24 | const float c_finiteDifferencesEpsilon = 0.01f; // The epsilon used in finite differences 25 | const size_t c_finiteDifferencesThreadSize = 100; // How many weights should each thread handle when doing finite differences? 26 | 27 | // Our neural network has: 28 | // * 784 input neurons. 1 input neuron for each pixel. 29 | // * 30 hidden neurons. To help find how to match input to output. 30 | // * 10 output neurons. To specify the digit 0 to 9. 31 | using TNeuralNetwork = NeuralNetwork; 32 | 33 | struct DataItem; 34 | 35 | std::span GetGradient_FiniteDifferences_Central(TNeuralNetwork& neuralNet, const DataItem& dataItem); 36 | std::span GetGradient_FiniteDifferences_Forward(TNeuralNetwork& neuralNet, const DataItem& dataItem); 37 | std::span GetGradient_DualNumbers(TNeuralNetwork& neuralNet, const DataItem& dataItem); 38 | std::span GetGradient_Backprop(TNeuralNetwork& neuralNet, const DataItem& dataItem); -------------------------------------------------------------------------------- /Training/StackPoolAllocator.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // Machine Learning Introduction For Game Developers // 3 | // Copyright (c) 2023 Electronic Arts Inc. All rights reserved. // 4 | /////////////////////////////////////////////////////////////////////////////// 5 | 6 | #pragma once 7 | 8 | #include 9 | #include 10 | 11 | // A stack allocator that is also strongly typed 12 | 13 | template 14 | class StackPoolAllocator 15 | { 16 | public: 17 | StackPoolAllocator(size_t maxCount) 18 | { 19 | // Max size must be set in advance to not make pointers invalid while this is in use. 20 | m_storage.resize(maxCount); 21 | } 22 | 23 | inline void Reset() 24 | { 25 | m_nextFree = 0; 26 | } 27 | 28 | template 29 | inline std::span Allocate() 30 | { 31 | // Allocate space 32 | T* ret = &m_storage[m_nextFree]; 33 | m_nextFree += COUNT; 34 | 35 | // nullptr when we run out of space. 36 | if (m_nextFree > m_storage.size()) 37 | return std::span{ (T*)nullptr, COUNT }; 38 | 39 | // Make the values clean 40 | auto retSpan = std::span{ ret, COUNT }; 41 | 42 | if (INITIALIZE) 43 | { 44 | T dflt = {}; 45 | std::fill(retSpan.begin(), retSpan.end(), dflt); 46 | } 47 | 48 | // Return the data 49 | return retSpan; 50 | } 51 | 52 | inline std::span Allocate(size_t count, bool initialize) 53 | { 54 | // Allocate space 55 | T* ret = &m_storage[m_nextFree]; 56 | m_nextFree += count; 57 | 58 | // nullptr when we run out of space. 59 | if (m_nextFree > m_storage.size()) 60 | return std::span{ (T*)nullptr, 0 }; 61 | 62 | // Make the values clean 63 | auto retSpan = std::span{ ret, count }; 64 | if (initialize) 65 | { 66 | T dflt = {}; 67 | std::fill(retSpan.begin(), retSpan.end(), dflt); 68 | } 69 | 70 | // Return the data 71 | return retSpan; 72 | } 73 | 74 | private: 75 | size_t m_nextFree = 0; 76 | std::vector m_storage; 77 | }; 78 | -------------------------------------------------------------------------------- /Training/Training.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | stb 15 | 16 | 17 | stb 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | {a315bce1-e785-4bc7-b167-040582fe7f98} 26 | 27 | 28 | -------------------------------------------------------------------------------- /Training/Training.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Training/out/Backprop_Accuracy.csv: -------------------------------------------------------------------------------- 1 | "Epoch","Backprop" 2 | "1","91.459999" 3 | "2","92.830002" 4 | "3","92.820000" 5 | "4","94.120003" 6 | "5","94.190002" 7 | "6","94.550003" 8 | "7","94.900002" 9 | "8","94.510002" 10 | "9","94.769997" 11 | "10","94.940002" 12 | "11","95.070000" 13 | "12","95.199997" 14 | "13","95.180000" 15 | "14","95.349998" 16 | "15","95.389999" 17 | "16","95.239998" 18 | "17","95.559998" 19 | "18","95.250000" 20 | "19","95.400002" 21 | "20","95.410004" 22 | "21","95.419998" 23 | "22","95.180000" 24 | "23","95.519997" 25 | "24","95.230003" 26 | "25","95.440002" 27 | "26","95.449997" 28 | "27","95.730003" 29 | "28","95.430000" 30 | "29","95.610001" 31 | "30","95.540001" 32 | -------------------------------------------------------------------------------- /Training/out/Backprop_Weights.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronicarts/cpp-ml-intro/682222d9993d122749723b54d8d6064d6117288a/Training/out/Backprop_Weights.bin -------------------------------------------------------------------------------- /logo/SEED.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronicarts/cpp-ml-intro/682222d9993d122749723b54d8d6064d6117288a/logo/SEED.jpg --------------------------------------------------------------------------------