Code Monkey home page Code Monkey logo

sdl-bgfx-imgui-starter's Introduction

sdl-bgfx-imgui-starter

starter

The idea behind this repo is for it to be used as a minimal starting point for development of a game, demo or prototype.

It utilizes SDL2 for the windowing system, bgfx (by @bkaradzic) for the graphics library and Dear ImGui (by @ocornut) for the user interface.

The code in main.cpp is derived from two excellent bgfx tutorials (hello-bgfx by Phil Peron and bgfx-ubuntu by Sandeep Nambiar). I highly recommend checking them out.

This repo does not directly include any of these dependencies. Instead, CMake is used to download and install them so this project can use them. This is handled through the use of a superbuild.

Prerequisites

To begin with create a directory to hold the repo:

mkdir sdl-bgfx-imgui-starter
cd sdl-bgfx-imgui-starter

Then clone the repo:

git clone https://github.com/pr0g/sdl-bgfx-imgui-starter.git .

This project comes with a superbuild CMake script which will build all third party dependencies and the main application in one step. The third party dependencies are built and installed to a separate build folder in the third party directory. To achieve this CMake must be installed on your system (the repo has most recently been tested with CMake version 3.24).

Note: It is possible to build the third party dependencies separately, but the configure scripts described below now default to use -DSUPERBUILD=ON (as this is the simplest and most common workflow). If you do wish to build the third party dependencies separately, please see the third party README for full instructions on how to do this.

Note: When building the dependencies, the libraries are by default self contained in the repo and are not installed to the system.

Build Instructions

All

Shaders for bgfx must be compiled to be loaded by the application (the starter has an incredibly simple shader supporting vertex colours). See compile-shaders-<platform>.sh/bat for details. shaderc is built as part of bgfx when first building the repo and is used to compile the shaders.

Note: A number of configure-<generator>.bat/sh files are provided to run the CMake configure commands. Ninja is preferred as it's consistent across macOS, Linux and Windows (and it's very fast), any generator should work though. For example there's a configure-vs-19/22.bat for generating a Visual Studio 2019 or 2022 solution.

Windows

  • Run configure-vs-19.bat, configure-vs-22.bat or configure-ninja.bat located in the root directory to generate the build files required for the project.
  • Run cmake --build build\debug-ninja and/or cmake --build build\release-ninja to compile the project using Ninja or cmake --build build\vs<year> --config Debug and/or cmake --build build\vs<year> --config Release if using the Visual Studio generator.
  • Run compile-shaders-win.bat located in the root directory to build the shaders.
  • Launch the application by running build\debug-ninja\sdl-bgfx-imgui-starter.exe or build\release-ninja\sdl-bgfx-imgui-starter.exe if using Ninja or build\vs<year>\Debug\sdl-bgfx-imgui-starter.exe or build\vs<year>\Release\sdl-bgfx-imgui-starter.exe if using Visual Studio.

macOS

  • Run ./configure-make.sh or ./configure-ninja.sh located in the root directory to generate the build files required for the project (prefer Ninja if possible as it's much faster).
  • Run cmake --build build/debug-<generator> and/or cmake --build build/release-<generator> to compile the project.
  • Run ./compile-shaders-macos.sh located in the root directory to build the shaders.
  • Launch the application by running ./build/debug-<generator>/sdl-bgfx-imgui-starter or ./build/release-<generator>/sdl-bgfx-imgui-starter.

Linux

  • Check the prerequisites when first starting out on Linux to ensure you have all the fundamentals (e.g. X11, OpenGL, Ninja etc...).
  • Run ./configure-make.sh or ./configure-ninja.sh located in the root directory to generate the build files required for the project (prefer Ninja if possible as it's much faster).
  • Run cmake --build build/debug-<generator> and/or cmake --build build/release-<generator> to compile the project.
  • Run ./compile-shaders-linux.sh located in the root directory to build the shaders.
  • Launch the application by running ./build/debug-<generator>/sdl-bgfx-imgui-starter or ./build/release-<generator>/sdl-bgfx-imgui-starter.

Emscripten (Windows/macOS/Linux)

Note: Emscripten is built in a separate build folder called embuild, not build. This is to prevent Emscripten from overwriting native builds when built separately.

Note: On Windows it may be necessary to run the command-line/terminal as Administrator when building Emscripten.

  • Ensure you have Python installed on your system.
  • Follow the install steps to setup Emscripten here (This is required to be able to use the emcmake command in the various configure scripts).
  • Run ./configure-emscripten.<bat/sh> from the root directory.
    • Ensure emsdk_env.bat or source ./emsdk_env.sh have been run before attempting this so emcmake is added to the path (see Emscripten instructions above for more details).
  • Run ./compile-shaders-emscripten.<bat/sh> located in the root directory. (Note: In order to invoke shaderc, the third party dependencies (specifically bgfx) will have to have been built for the target platform as well as Emscripten, so the shaders can be compiled). The build step for Emscripten copies the built shaders to the build folder (embuild), so compiling the shaders should happen before the main Emscripten build.
  • Run cmake --build embuild/debug-emscripten and/or cmake --build embuild/release-emscripten.
  • Start a local server (the easiest way to do this is with python3 -m http.server).
  • Go to localhost:8000 in a browser and open embuild/<debug/release>-emscripten/sdl-bgfx-imgui-starter.html.

Resources

While getting this project setup I discovered a number of excellent resources. I'd highly recommend checking them out to learn more about bgfx and Dear ImGui.

  • bgfx - bgfx main repo.
  • bgfx docs - extensive docs covering much of bgfx's API.
  • bkaradzic/bgfx.cmake (originally widberg/bgfx.cmake) - a complimentary repo to add CMake support to bgfx (used by this repo).
  • hello-bgfx (tutorial) - a great intro to bgfx and covers most of the code in the main.cpp of this repo.
  • bgfx-ubuntu(tutorial) - another great tutorial on bgfx (showing how to get setup on Ubuntu).
  • minimal-bgfx - a similar repo to this one only using premake and git submodules instead of CMake and with no Dear ImGui.
  • dear-imgui - Dear ImGui main repo - lots of documentation and examples are available there.
  • cmakefied - a complimentary repo to add CMake support to imgui (originally used by this repo but now replaced with a simpler repo called imgui.cmake, similar in design to bgfx.cmake mentioned above).

Special Thanks

sdl-bgfx-imgui-starter's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

sdl-bgfx-imgui-starter's Issues

Automatically running third party cMakeLists.txt

I am starting on a project that needs bgfx and I would like to use cmake for the build. Since I am new to cmake, I am using this "sdl-bgfx-imgui-starter" as an example of how to go about (Thank you for providing it!).

However, the setup here involves an extra manual step for the user: The user has to first "cd" to the "third-party" folder and run "cmake -B build". What changes are needed to make that automatically happen as part of building the main project? An example of doing that would be great. I would also appreciate any pointers and guidance!

Thanks.

Release config always builds Debug with Visual Studio 2017 22

Hi!

Been working with your starter template for a while using the Debug config but I also want to build the Release config now.

According to the third-party install instructions I should be able to run:

cmake -B build -G "Visual Studio 17 2022"

and then

cmake --build build --config Release.

But this creates Debug folders and according to the logs (-- Install configuration: "Debug" before installing the SDL lib) every library (SDL2, bgfx, etc..) still builds with Debug configuration.

What am I doing wrong?
Thanks!

LINK : fatal error LNK1104: cannot open file 'C:\dev\my\cpp\sdl-bgfx-imgui-starter\third-party\build\bgfx\build\Debug\spirv-toolsd.lib'

Hey ,
Tryin to build the startre kit , win10 64bit , VC++ 2022
got this error :

c:\dev\my\cpp\sdl-bgfx-imgui-starter\third-party>cmake --build build
Microsoft (R) Build Engine version 17.0.0+c9eb9dd64 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

  Performing update step for 'bgfx'
  No patch step for 'bgfx'
  Performing configure step for 'bgfx'
  -- Selecting Windows SDK version 10.0.20348.0 to target Windows 10.0.19043.
  -- Configuring done
  -- Generating done
  -- Build files have been written to: C:/dev/my/cpp/sdl-bgfx-imgui-starter/third-party/build/bgfx/build
  Performing build step for 'bgfx'
  Microsoft (R) Build Engine version 17.0.0+c9eb9dd64 for .NET Framework
  Copyright (C) Microsoft Corporation. All rights reserved.

    Checking Build System
    Building Custom Rule C:/dev/my/cpp/sdl-bgfx-imgui-starter/third-party/build/bgfx-prefix/src/bgfx/CMakeLists.txt
    astc.vcxproj -> C:\dev\my\cpp\sdl-bgfx-imgui-starter\third-party\build\bgfx\build\Debug\astcd.lib
    Building Custom Rule C:/dev/my/cpp/sdl-bgfx-imgui-starter/third-party/build/bgfx-prefix/src/bgfx/CMakeLists.txt
    astc-codec.vcxproj -> C:\dev\my\cpp\sdl-bgfx-imgui-starter\third-party\build\bgfx\build\Debug\astc-codecd.lib
    Building Custom Rule C:/dev/my/cpp/sdl-bgfx-imgui-starter/third-party/build/bgfx-prefix/src/bgfx/CMakeLists.txt
    bx.vcxproj -> C:\dev\my\cpp\sdl-bgfx-imgui-starter\third-party\build\bgfx\build\Debug\bxd.lib
    Building Custom Rule C:/dev/my/cpp/sdl-bgfx-imgui-starter/third-party/build/bgfx-prefix/src/bgfx/CMakeLists.txt
    edtaa3.vcxproj -> C:\dev\my\cpp\sdl-bgfx-imgui-starter\third-party\build\bgfx\build\Debug\edtaa3d.lib
    Building Custom Rule C:/dev/my/cpp/sdl-bgfx-imgui-starter/third-party/build/bgfx-prefix/src/bgfx/CMakeLists.txt
    etc1.vcxproj -> C:\dev\my\cpp\sdl-bgfx-imgui-starter\third-party\build\bgfx\build\Debug\etc1d.lib
    Building Custom Rule C:/dev/my/cpp/sdl-bgfx-imgui-starter/third-party/build/bgfx-prefix/src/bgfx/CMakeLists.txt
    etc2.vcxproj -> C:\dev\my\cpp\sdl-bgfx-imgui-starter\third-party\build\bgfx\build\Debug\etc2d.lib
    Building Custom Rule C:/dev/my/cpp/sdl-bgfx-imgui-starter/third-party/build/bgfx-prefix/src/bgfx/CMakeLists.txt
    iqa.vcxproj -> C:\dev\my\cpp\sdl-bgfx-imgui-starter\third-party\build\bgfx\build\Debug\iqad.lib
    Building Custom Rule C:/dev/my/cpp/sdl-bgfx-imgui-starter/third-party/build/bgfx-prefix/src/bgfx/CMakeLists.txt
    nvtt.vcxproj -> C:\dev\my\cpp\sdl-bgfx-imgui-starter\third-party\build\bgfx\build\Debug\nvttd.lib
    Building Custom Rule C:/dev/my/cpp/sdl-bgfx-imgui-starter/third-party/build/bgfx-prefix/src/bgfx/CMakeLists.txt
    pvrtc.vcxproj -> C:\dev\my\cpp\sdl-bgfx-imgui-starter\third-party\build\bgfx\build\Debug\pvrtcd.lib
    Building Custom Rule C:/dev/my/cpp/sdl-bgfx-imgui-starter/third-party/build/bgfx-prefix/src/bgfx/CMakeLists.txt
    squish.vcxproj -> C:\dev\my\cpp\sdl-bgfx-imgui-starter\third-party\build\bgfx\build\Debug\squishd.lib
    Building Custom Rule C:/dev/my/cpp/sdl-bgfx-imgui-starter/third-party/build/bgfx-prefix/src/bgfx/CMakeLists.txt
    tinyexr.vcxproj -> C:\dev\my\cpp\sdl-bgfx-imgui-starter\third-party\build\bgfx\build\Debug\tinyexrd.lib
    Building Custom Rule C:/dev/my/cpp/sdl-bgfx-imgui-starter/third-party/build/bgfx-prefix/src/bgfx/CMakeLists.txt
    bimg.vcxproj -> C:\dev\my\cpp\sdl-bgfx-imgui-starter\third-party\build\bgfx\build\Debug\bimgd.lib
    Building Custom Rule C:/dev/my/cpp/sdl-bgfx-imgui-starter/third-party/build/bgfx-prefix/src/bgfx/CMakeLists.txt
    bgfx.vcxproj -> C:\dev\my\cpp\sdl-bgfx-imgui-starter\third-party\build\bgfx\build\Debug\bgfxd.lib
    Building Custom Rule C:/dev/my/cpp/sdl-bgfx-imgui-starter/third-party/build/bgfx-prefix/src/bgfx/CMakeLists.txt
    fcpp.vcxproj -> C:\dev\my\cpp\sdl-bgfx-imgui-starter\third-party\build\bgfx\build\Debug\fcppd.lib
    Building Custom Rule C:/dev/my/cpp/sdl-bgfx-imgui-starter/third-party/build/bgfx-prefix/src/bgfx/CMakeLists.txt
    meshoptimizer.vcxproj -> C:\dev\my\cpp\sdl-bgfx-imgui-starter\third-party\build\bgfx\build\Debug\meshoptimizerd.lib
    Building Custom Rule C:/dev/my/cpp/sdl-bgfx-imgui-starter/third-party/build/bgfx-prefix/src/bgfx/CMakeLists.txt
    geometryc.vcxproj -> C:\dev\my\cpp\sdl-bgfx-imgui-starter\third-party\build\bgfx\build\Debug\geometryc.exe
    Building Custom Rule C:/dev/my/cpp/sdl-bgfx-imgui-starter/third-party/build/bgfx-prefix/src/bgfx/CMakeLists.txt
    dear-imgui.vcxproj -> C:\dev\my\cpp\sdl-bgfx-imgui-starter\third-party\build\bgfx\build\Debug\dear-imguid.lib
    Building Custom Rule C:/dev/my/cpp/sdl-bgfx-imgui-starter/third-party/build/bgfx-prefix/src/bgfx/CMakeLists.txt
    example-common.vcxproj -> C:\dev\my\cpp\sdl-bgfx-imgui-starter\third-party\build\bgfx\build\Debug\example-commond.lib
    Building Custom Rule C:/dev/my/cpp/sdl-bgfx-imgui-starter/third-party/build/bgfx-prefix/src/bgfx/CMakeLists.txt
    geometryv.vcxproj -> C:\dev\my\cpp\sdl-bgfx-imgui-starter\third-party\build\bgfx\build\Debug\geometryv.exe
    Building Custom Rule C:/dev/my/cpp/sdl-bgfx-imgui-starter/third-party/build/bgfx-prefix/src/bgfx/CMakeLists.txt
    glcpp.vcxproj -> C:\dev\my\cpp\sdl-bgfx-imgui-starter\third-party\build\bgfx\build\Debug\glcppd.lib
    Building Custom Rule C:/dev/my/cpp/sdl-bgfx-imgui-starter/third-party/build/bgfx-prefix/src/bgfx/CMakeLists.txt
    mesa.vcxproj -> C:\dev\my\cpp\sdl-bgfx-imgui-starter\third-party\build\bgfx\build\Debug\mesad.lib
    Building Custom Rule C:/dev/my/cpp/sdl-bgfx-imgui-starter/third-party/build/bgfx-prefix/src/bgfx/CMakeLists.txt
    glsl-optimizer.vcxproj -> C:\dev\my\cpp\sdl-bgfx-imgui-starter\third-party\build\bgfx\build\Debug\glsl-optimizerd.lib
    Building Custom Rule C:/dev/my/cpp/sdl-bgfx-imgui-starter/third-party/build/bgfx-prefix/src/bgfx/CMakeLists.txt
    glslang.vcxproj -> C:\dev\my\cpp\sdl-bgfx-imgui-starter\third-party\build\bgfx\build\Debug\glslangd.lib
    Building Custom Rule C:/dev/my/cpp/sdl-bgfx-imgui-starter/third-party/build/bgfx-prefix/src/bgfx/CMakeLists.txt
    spirv-cross.vcxproj -> C:\dev\my\cpp\sdl-bgfx-imgui-starter\third-party\build\bgfx\build\Debug\spirv-crossd.lib
    Building Custom Rule C:/dev/my/cpp/sdl-bgfx-imgui-starter/third-party/build/bgfx-prefix/src/bgfx/CMakeLists.txt
LINK : fatal error LNK1104: cannot open file 'C:\dev\my\cpp\sdl-bgfx-imgui-starter\third-party\build\bgfx\build\Debug\spirv-toolsd.lib' [C:\dev\my\cpp\sdl-bgfx-imgui-starter\third-party\build\bgfx\build\spirv
-tools.vcxproj] [C:\dev\my\cpp\sdl-bgfx-imgui-starter\third-party\build\bgfx.vcxproj]
    Building Custom Rule C:/dev/my/cpp/sdl-bgfx-imgui-starter/third-party/build/bgfx-prefix/src/bgfx/CMakeLists.txt
    texturec.cpp
       Creating library C:/dev/my/cpp/sdl-bgfx-imgui-starter/third-party/build/bgfx/build/Debug/texturec.lib and object C:/dev/my/cpp/sdl-bgfx-imgui-starter/third-party/build/bgfx/build/Debug/texturec.exp
    texturec.vcxproj -> C:\dev\my\cpp\sdl-bgfx-imgui-starter\third-party\build\bgfx\build\Debug\texturec.exe
    Building Custom Rule C:/dev/my/cpp/sdl-bgfx-imgui-starter/third-party/build/bgfx-prefix/src/bgfx/CMakeLists.txt
    texturev.cpp
C:\dev\my\cpp\sdl-bgfx-imgui-starter\third-party\build\bgfx-prefix\src\bgfx\bgfx\3rdparty\dear-imgui\widgets/memory_editor.h(20,13): warning C4996: 'strcpy': This function or variable may be unsafe. Consider
using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [C:\dev\my\cpp\sdl-bgfx-imgui-starter\third-party\build\bgfx\build\texturev.vcxproj] [C:\dev\my\cpp\sd
l-bgfx-imgui-starter\third-party\build\bgfx.vcxproj]
C:\dev\my\cpp\sdl-bgfx-imgui-starter\third-party\build\bgfx-prefix\src\bgfx\bgfx\3rdparty\dear-imgui\widgets/memory_editor.h(21,13): warning C4996: 'strcpy': This function or variable may be unsafe. Consider
using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [C:\dev\my\cpp\sdl-bgfx-imgui-starter\third-party\build\bgfx\build\texturev.vcxproj] [C:\dev\my\cpp\sd
l-bgfx-imgui-starter\third-party\build\bgfx.vcxproj]
       Creating library C:/dev/my/cpp/sdl-bgfx-imgui-starter/third-party/build/bgfx/build/Debug/texturev.lib and object C:/dev/my/cpp/sdl-bgfx-imgui-starter/third-party/build/bgfx/build/Debug/texturev.exp
    texturev.vcxproj -> C:\dev\my\cpp\sdl-bgfx-imgui-starter\third-party\build\bgfx\build\Debug\texturev.exe
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(242,5): error MSB8066: Custom build for 'C:\dev\my\cpp\sdl-bgfx-imgui-starter\third-party\build\CM
akeFiles\91c4a5e23bc15095b2da2fac268ecfc1\bgfx-update.rule;C:\dev\my\cpp\sdl-bgfx-imgui-starter\third-party\build\CMakeFiles\91c4a5e23bc15095b2da2fac268ecfc1\bgfx-patch.rule;C:\dev\my\cpp\sdl-bgfx-imgui-start
er\third-party\build\CMakeFiles\91c4a5e23bc15095b2da2fac268ecfc1\bgfx-configure.rule;C:\dev\my\cpp\sdl-bgfx-imgui-starter\third-party\build\CMakeFiles\91c4a5e23bc15095b2da2fac268ecfc1\bgfx-build.rule;C:\dev\m
y\cpp\sdl-bgfx-imgui-starter\third-party\build\CMakeFiles\91c4a5e23bc15095b2da2fac268ecfc1\bgfx-install.rule;C:\dev\my\cpp\sdl-bgfx-imgui-starter\third-party\build\CMakeFiles\47218f6ffe17cb1a08339cee0e6bf7d3\
bgfx-complete.rule;C:\dev\my\cpp\sdl-bgfx-imgui-starter\third-party\build\CMakeFiles\e3a0df0db7afd2eaad2a5d96f3e16bfb\bgfx.rule' exited with code 1. [C:\dev\my\cpp\sdl-bgfx-imgui-starter\third-party\build\bgf
x.vcxproj]
  Creating directories for 'imgui.cmake'
  Building Custom Rule C:/dev/my/cpp/sdl-bgfx-imgui-starter/third-party/CMakeLists.txt
  Performing download step (git clone) for 'imgui.cmake'
  Cloning into 'imgui.cmake'...
  HEAD is now at 7e417a3 update imgui library
  Submodule 'imgui' (https://github.com/ocornut/imgui) registered for path 'imgui'
  Cloning into 'C:/dev/my/cpp/sdl-bgfx-imgui-starter/third-party/build/imgui.cmake-prefix/src/imgui.cmake/imgui'...
  Submodule path 'imgui': checked out '07efd7cc2053099c2f29e65b33e03d56a4b8d53c'
  Performing update step for 'imgui.cmake'
  No patch step for 'imgui.cmake'
  Performing configure step for 'imgui.cmake'
  -- Selecting Windows SDK version 10.0.20348.0 to target Windows 10.0.19043.
  -- The CXX compiler identification is MSVC 19.30.30705.0
  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - done
  -- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.30.30705/bin/Hostx64/x64/cl.exe - skipped
  -- Detecting CXX compile features
  -- Detecting CXX compile features - done
  -- Configuring done
  -- Generating done
  -- Build files have been written to: C:/dev/my/cpp/sdl-bgfx-imgui-starter/third-party/build/imgui/build
  Performing build step for 'imgui.cmake'
  Microsoft (R) Build Engine version 17.0.0+c9eb9dd64 for .NET Framework
  Copyright (C) Microsoft Corporation. All rights reserved.

    Checking Build System
    Building Custom Rule C:/dev/my/cpp/sdl-bgfx-imgui-starter/third-party/build/imgui.cmake-prefix/src/imgui.cmake/CMakeLists.txt
    imgui.cpp
    imgui_demo.cpp
    imgui_draw.cpp
    imgui_widgets.cpp
    imgui_tables.cpp
    Generating Code...
    imgui.cmake.vcxproj -> C:\dev\my\cpp\sdl-bgfx-imgui-starter\third-party\build\imgui\build\Debug\imgui.cmaked.lib
    Building Custom Rule C:/dev/my/cpp/sdl-bgfx-imgui-starter/third-party/build/imgui.cmake-prefix/src/imgui.cmake/CMakeLists.txt
  Performing install step for 'imgui.cmake'
  Microsoft (R) Build Engine version 17.0.0+c9eb9dd64 for .NET Framework
  Copyright (C) Microsoft Corporation. All rights reserved.

    imgui.cmake.vcxproj -> C:\dev\my\cpp\sdl-bgfx-imgui-starter\third-party\build\imgui\build\Debug\imgui.cmaked.lib
    -- Install configuration: "Debug"
    -- Installing: C:/dev/my/cpp/sdl-bgfx-imgui-starter/third-party/build/lib/imgui.cmaked.lib
    -- Installing: C:/dev/my/cpp/sdl-bgfx-imgui-starter/third-party/build/lib/cmake/imgui.cmake/imgui.cmake-config.cmake
    -- Installing: C:/dev/my/cpp/sdl-bgfx-imgui-starter/third-party/build/lib/cmake/imgui.cmake/imgui.cmake-config-debug.cmake
    -- Installing: C:/dev/my/cpp/sdl-bgfx-imgui-starter/third-party/build/include/imgui.h
  Completed 'imgui.cmake'

Could not find SDL2Config.cmake, sdl2-config.cmake

I get a CMake error when using "cmake -S . -B build":

CMake Error at CMakeLists.txt:5 (find_package):
Could not find a package configuration file provided by "SDL2" with any of
the following names:

SDL2Config.cmake
sdl2-config.cmake

Add the installation prefix of "SDL2" to CMAKE_PREFIX_PATH or set
"SDL2_DIR" to a directory containing one of the above files. If "SDL2"
provides a separate development package or SDK, be sure it has been
installed.

-- Configuring incomplete, errors occurred!
See also "C:/dev/sdl-bgfx-imgui-starter/build/CMakeFiles/CMakeOutput.log".

It might only be my system, but shouldn't 'cmake -S . -B build" work without any further configuration from my part?

Multi-viewport support?

Hello,

Thank you so much for the starter kit of sdl bgfx and imgui.
I was able successfully integrate it with c99 project using cimgui.

I have a question for you. Have you figured out docking branch support of imgui? I got docking working out of the box with impl_bgfx but not able to support multi-viewport since bgfx clips off the rendering of imgui windows which are not in SDL window rect.

Thank you.

Help with compilation

Good day, I stumbled across this as one of the possible examples of the "bgfx" library usage in their documentation. I'm unsure if this is still supported, but I tried it nevertheless. I attempted to use the CMake GUI, as well as following the instructions as closely as I could, but I am a total newbie when it comes to C++ and libraries, and I'm not sure where to start learning, so I've just been messing around with projects.

I've attempted to get the project up and running, but have hit a couple of walls. The root CMake script seems to have an issue with finding SDL2 even when pre-compiling the third party binaries. Since I am using VS Code, I have my launch.json mapped to the root "CMakeLists.txt," which does not run or inherit any subdirectories to my knowledge. Wasn't really sure where to ask, but I have tried to follow all instructions for compiling or trying to get the starter program to run, and even when I just click on the executable file it opens and closes immediately. Again, I am a total beginner, so I completely understand if some of this is either hazy or if I messed up on my end. Thank you!

Compiling multiple files?

Hello, this project has been very helpful and I was able to follow the instructions to get the demo working. I decided to use this project as a starting point for my engine, and ran into problems when I started abstracting into multiple classes.

See, I created a Window.h header file with the following definition:

class Window {
private:
    SDL_Window* window;
    int width, height;

public:
    Window(const char* title, int width, int height);
    ~Window();
};

and a Window.cpp file with the following implementation:

Window::Window(const char* title, int w, int h) {
    width = w; height = h;
    window = SDL_CreateWindow(title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, SDL_WINDOW_SHOWN);
    
    if (window == NULL) {
    printf("Window could not be created! SDL_Error: %s\n",
            SDL_GetError());
    }
}

Window::~Window() {
    SDL_DestroyWindow(window);
}

I then used the window class in my main.cpp file and got the following error

Undefined symbols for architecture arm64:
  "Window::Window(char const*, int, int)", referenced from:
      _main in main.cpp.o
  "Window::~Window()", referenced from:
      _main in main.cpp.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I have little knowledge of cmake, but I think this has to do with the implementation in the window.cpp file not being compiled (and there are several direct mentions of main.cpp instead of a wildcard *.cpp). When I put the implementation in the main.cpp file, everything worked perfectly. I would appreciate if anyone could help me get all files compiling?

Other Information:
Using Mac OS
Build commands:

debug:
	cmake --build build/debug-make
	./compile-shaders-macos.sh

release:
	cmake --build build/release-make
	./compile-shaders-macos.sh

Error

zhangfq@zhangfq-Precision-3640-Tower:~/zhangfq/sdl-bgfx-imgui-starter$ ./configure.sh
-- Configuring done
CMake Error at CMakeLists.txt:9 (add_executable):
Target "sdl-bgfx-imgui-starter" links to target "imgui::imgui" but the
target was not found. Perhaps a find_package() call is missing for an
IMPORTED target, or an ALIAS target is missing?

The source directory does not appear to contain CMakeLists.txt

I'm getting a The source directory "(project)/third-party/build/bgfx-prefix/src/bgfx" does not appear to contain CMakeLists.txt error when installing third party dependencies.

w/ Windows 11 Home 21H2 (22000.100), Visual Studio 2019

(project)\third-party> cmake -S . -B build
...
-- Build files have been written to: (project)/third-party/build
(project)\third-party> cmake --build build
... SDL stuff ...

  Completed 'SDL2'
  Building Custom Rule (project)/third-party/CMakeLists.txt
  Creating directories for 'bgfx'
  Performing download step (git clone) for 'bgfx'
  Cloning into 'bgfx'...
  fatal: reference is not a tree: 86b4b5a610e8bde42eb259cddc75046bc865929b
  Performing update step (git update) for 'bgfx'
  fatal: reference is not a tree: 86b4b5a610e8bde42eb259cddc75046bc865929b
  Skipping patch step (no custom command) for 'bgfx'
  Performing configure step for 'bgfx'
CUSTOMBUILD : CMake error : The source directory "(project)/third-party/build/bgfx-prefix/src/bgfx" does not appear to
contain CMakeLists.txt. [(project)\third-party\build\bgfx.vcxproj]
  Specify --help for usage, or press the help button on the CMake GUI.
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(241
,5): error MSB8066: Custom build for '(project)\third-party\build\CMakeFiles\f116f8cdce7e848021a1badd9f84fe6c\bgfx-mkdi
r.rule;(project)\third-party\build\CMakeFiles\f116f8cdce7e848021a1badd9f84fe6c\bgfx-download.rule;(project)\third-party
\build\CMakeFiles\f116f8cdce7e848021a1badd9f84fe6c\bgfx-update.rule;(project)\third-party\build\CMakeFiles\f116f8cdce7e
848021a1badd9f84fe6c\bgfx-patch.rule;(project)\third-party\build\CMakeFiles\f116f8cdce7e848021a1badd9f84fe6c\bgfx-confi
gure.rule;(project)\third-party\build\CMakeFiles\f116f8cdce7e848021a1badd9f84fe6c\bgfx-build.rule;(project)\third-party
\build\CMakeFiles\f116f8cdce7e848021a1badd9f84fe6c\bgfx-install.rule;(project)\third-party\build\CMakeFiles\695b9bc5562
12bbbc88c09bdb74a0535\bgfx-complete.rule;(project)\third-party\build\CMakeFiles\90f9981f2512798baefc1ece0eea96ee\bgfx.r
ule' exited with code 1. [(project)\third-party\build\bgfx.vcxproj]
  Creating directories for 'cmakefied'
  Performing download step (git clone) for 'cmakefied'
  Cloning into 'cmakefied'...
  HEAD is now at 5b201e9 provide option to define IMGUI_DISABLE_OBSOLETE_FUNCTIONS when building imgui
  Performing update step (custom command) for 'cmakefied'
  /bin/bash: (project)/third-party/build/cmakefied-prefix/src/cmakefied/git-clone.sh: No such file or directory
  CMake Error at E:/Programs/CMake/share/cmake-3.20/Modules/ExternalProject/captured_process_setup.cmake:29 (message):
  Call Stack (most recent call first):
    E:/Programs/CMake/share/cmake-3.20/Modules/ExternalProject/captured_process_setup.cmake:53 (_ep_message_quiet_captu
  re)
    cmakefied-prefix/tmp/cmakefied-update.cmake:16 (_ep_command_check_result)


C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(241
,5): error MSB8066: Custom build for '(project)\third-party\build\CMakeFiles\a2fec6abecb558db70dbad2d30ae473a\cmakefied
-mkdir.rule;(project)\third-party\build\CMakeFiles\a2fec6abecb558db70dbad2d30ae473a\cmakefied-download.rule;(project)\t
hird-party\build\CMakeFiles\a2fec6abecb558db70dbad2d30ae473a\cmakefied-update.rule;(project)\third-party\build\CMakeFil
es\a2fec6abecb558db70dbad2d30ae473a\cmakefied-patch.rule;(project)\third-party\build\CMakeFiles\a2fec6abecb558db70dbad2
d30ae473a\cmakefied-configure.rule;(project)\third-party\build\CMakeFiles\a2fec6abecb558db70dbad2d30ae473a\cmakefied-bu
ild.rule;(project)\third-party\build\CMakeFiles\a2fec6abecb558db70dbad2d30ae473a\cmakefied-install.rule;project\third
-party\build\CMakeFiles\695b9bc556212bbbc88c09bdb74a0535\cmakefied-complete.rule;project\third-party\build\CMakeFiles
\90f9981f2512798baefc1ece0eea96ee\cmakefied.rule' exited with code 1. [(project)\third-party\build\cmakefied.vcxproj]

Can't compile under windows using clang

Hi!

The starter works perfectly well on windows with MSVC but won't compile for me if I use clang.

My setup:

  1. Install msys2: https://www.msys2.org/
  2. Open MSYS UCRT64
  3. pacman -S mingw-w64-x86_64-cmake
  4. pacman -S mingw-w64-x86_64-ninja
  5. pacman -S mingw-w64-x86_64-clang

And I configured the project using configure-ninja.bat.
Then I started building and it seems like it doesn't know the cstdint types:

bgfxproject/third-party/build/src/bgfx/bgfx/3rdparty/glslang/glslang/MachineIndependent/SymbolTable.h:662:22: note: 'uint64_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?  

bgfxproject/third-party/build/src/bgfx/bgfx/3rdparty/glslang/glslang/MachineIndependent/SymbolTable.h:663:18: error: 'uint32_t' does not name a type
  663 |     static const uint32_t MaxLevelInUniqueID = 127;
      |                  ^~~~~~~~  

bgfxproject/third-party/build/src/bgfx/bgfx/3rdparty/glslang/glslang/MachineIndependent/SymbolTable.h:663:18: note: 'uint32_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?

Do you have an idea on how to solve this?

Full screen have multiple issues

Creating a full screen SDL_Window with flag SDL_WINDOW_FULLSCREEN_DESKTOP has multiple issues, see attached screenshot.

fullscreen Font looks blurry fullscreen_clipped Demo window got clipped when moved into a different position than the default one

Font display incorrectly for DearImgui?

Hi, after attempting to compile the code (I have to recompile the shader v_simple.sc and f_simple.sc using latest shaderc.exe from bgfx due to the fact that essl is missing, not sure if it's affected by that), the result is this:
image
DearImgui version is 1.83 (yes I tried to compile bgfx examples since they uses DearImgui too and font displayed correctly there so I think it's the issue with the sdl-bgfx-imgui-starter. I don't change anything in the main.cpp and bgfx-imgui and sdl-imgui beside the *.bin.h shader.

Here is the compiled result if you're wondering
fs_ocornut_imgui.bin.txt
vs_ocornut_imgui.bin.txt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.