Coder Social home page Coder Social logo

shalomfriss / sdl-bgfx-imgui-starter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pr0g/sdl-bgfx-imgui-starter

0.0 1.0 0.0 274 KB

A starter project for graphics applications using SDL, bgfx and Dear ImGui

CMake 1.64% C 45.69% C++ 28.75% Batchfile 1.46% Shell 22.16% Scala 0.08% SuperCollider 0.22%

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 experiment.

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 libraries but contains instructions on how to download and install them a CMake script to download and install them so this project can use them.

Warning: There is a little bit of setup required. Please see the prerequisites below.

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 .

Before attempting to build this project all third party dependencies (SDL, bgfx and imgui) must be downloaded and installed (CMake now takes care of this with ExternalProject_Add). To achieve this CMake must be installed on your system (repo tested with CMake version 3.15).

Note: The libraries are self contained in the repo and are not installed to the system.

Please see the third-party README for full instructions on how to do this.

Do not proceed to Build Instructions until you've done this.

Build Instructions

Once all third party libraries have been downloaded and installed, follow these build instructions to compile the repo.

Shaders for bgfx also must be compiled to be loaded by the application (the starter has an incredibly simple shader supporting vertex colours).

Info: A configure.bat and configure.sh file are provided (mainly as an exmaple) to run the CMake configure commands. Ninja was chosen as the generator for these as it's consistent across macOS, Linux and Windows, any generator should work though. There's also configure-vs.bat for generating a Visual Studio solution.

Windows

  • Run ./configure.bat located in the root directory to generate the build files required for the project.
  • Run cmake --build build/debug and/or cmake --build build/release to compile the project.
  • Run ./compile-shaders-win.bat located in the root directory to build the shaders.
  • Launch the application by running build\debug\sdl-bgfx-imgui-starter.exe or build\release\sdl-bgfx-imgui-starter.exe.

macOS

  • Run ./configure.sh located in the root directory to generate the build files required for the project.
  • Run cmake --build build/debug and/or cmake --build build/release 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/sdl-bgfx-imgui-starter or ./build/release/sdl-bgfx-imgui-starter.

Linux

  • Run ./configure.sh located in the root directory to generate the build files required for the project.
  • Run cmake --build build/debug and/or cmake --build build/release 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/sdl-bgfx-imgui-starter or ./build/release/sdl-bgfx-imgui-starter.

Emscripten (Windows/macOS/Linux)

  • Run ./configure-emscripten.<bat/sh> from the root directory.
  • Run cmake --build build/debug-emscripten and/or cmake --build build/release-emscripten.
  • 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).
  • Start a local server (easiest way to do this is with python3 -m http.server).
  • Go to localhost:8000 in a browser and open build/<debug/release>-emscripten/sdl-bgfx-imgui-starter.html.

Info: On Windows it may be necessary to run the command-line/terminal as Administrator.

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
  • 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 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 (used by this repo)

Special Thanks

sdl-bgfx-imgui-starter's People

Contributors

pr0g avatar

Watchers

James Cloos avatar

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.