Giter VIP home page Giter VIP logo

bgfx.cmake's Introduction

bgfx.cmake

Build Status

This repo contains a bunch of cmake files that can be used to build bgfx with CMake.

Building

git clone https://github.com/widberg/bgfx.cmake.git
cd bgfx.cmake
git submodule init
git submodule update
mkdir build
cd build
cmake ..

If downloading via zip (instead of using git submodules) manually download bx, bimg and bgfx and copy them into the root directory, or locate them via BX_DIR, BIMG_DIR and BGFX_DIR CMake variables.

How To Use

This project is setup to be included a few different ways. To include bgfx source code in your project simply use add_subdirectory to include this project. To build bgfx binaries build the INSTALL target (or "make install"). The installed files will be in the directory specified by CMAKE_INSTALL_PREFIX which I recommend you set to "./install" so it will export to your build directory. Note you may want to build install on both Release and Debug configurations.

Features

  • No outside dependencies besides bx, bimg, bgfx, and CMake.
  • Tested on Visual Studio 2015, Xcode, gcc 5.4, clang 3.8.
  • Compiles bgfx, tools & examples.
  • Detects shader modifications and automatically rebuilds them for all examples.

Does this work with latest bx/bgfx/bimg?

Probably! This project needs to be updated if a dependency is added or the bgfx build system changes. The bgfx repository is very active but these types of changes are rare. New examples have to be added manually as well, but not doing so will merely result in that example not showing up and won't break anything else. If pulling latest causes issues, be sure to manually reconfigure CMake as the glob patterns may need to be refreshed (the use of glob patterns in CMake is generally discouraged but in this project it helps to ensure upwards compatibilty with newer bgfx updates).

Todo

  • Support Native Client.
  • Support Windows Phone.
  • Fix iOS builds. #85
  • More configuration. #12
  • Add varying.def.sc files as shader dependencies.
  • Combined examples.

bgfx.cmake's People

Contributors

adynathos avatar alexandre-p-j avatar bdero avatar boberfly avatar brandonthehamm avatar bwrsandman avatar crazyjul avatar darkcontact avatar fireflyforlife avatar genuineaster avatar handsomematt avatar hartcw avatar hexlord avatar jonnyptn avatar joshuabrookover avatar lectem avatar leokolln avatar mean-ui-thread avatar onqtam avatar pezcode avatar pgruenbacher avatar pr0g avatar samaursa avatar synxis avatar trojanfoe avatar widberg avatar xgalaxy avatar yaz0r avatar

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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bgfx.cmake's Issues

Problem with setting up the project - undefined reference to symbol 'XFree'

Hi,

i'm kinda sorry to open this as issue, because i think the fault lies by with me - not in this project. But i could not think of another place where i could find help to this

i'm using ubuntu 17.04, and CLion as my IDE.

i created a new C++ Project. it contains my main.cpp, a CMakeLists.txt and a subfolder thirdparty.

i clone the bgfx.cmake repository into the thirdparty subfolder and changed my CMakeLists.txt to look like this:

cmake_minimum_required(VERSION 3.7)
set(CMAKE_CXX_STANDARD 14)
project(bgfx_test)

set(SOURCE_FILES main.cpp)

add_subdirectory("thirdparty/bgfx.cmake")
add_executable(bgfx_test ${SOURCE_FILES} )

target_link_libraries(bgfx_test bx)
target_link_libraries(bgfx_test bgfx)
target_link_libraries(bgfx_test bimg)

#target_include_directories(bgfx_test PUBLIC "cmake-build-debug/thirdparty/bgfx.cmake")

Then i changed my main.cpp to look like the HelloWorld example but with an empty update loop:

#include <bx/uint32_t.h>
#include <bgfx/bgfx.h>
#include "thirdparty/bgfx.cmake/bgfx/examples/common/common.h"
#include "thirdparty/bgfx.cmake/bgfx/examples/common/bgfx_utils.h"

class ExampleHelloWorld : public entry::AppI {
    int shutdown() BX_OVERRIDE {
        return 0;
    }

    bool update() BX_OVERRIDE {
        return false;
    }

    uint32_t m_width;
    uint32_t m_height;
    uint32_t m_debug;
    uint32_t m_reset;

    void init(int _argc, char** _argv) BX_OVERRIDE
    {
        Args args(_argc, _argv);

        m_width  = 1280;
        m_height = 720;
        m_debug  = BGFX_DEBUG_TEXT;
        m_reset  = BGFX_RESET_VSYNC;

        bgfx::init(args.m_type, args.m_pciId);
        bgfx::reset(m_width, m_height, m_reset);

        // Enable debug text.
        bgfx::setDebug(m_debug);

        // Set view 0 clear state.
        bgfx::setViewClear(0
                , BGFX_CLEAR_COLOR|BGFX_CLEAR_DEPTH
                , 0x303030ff
                , 1.0f
                , 0
        );
    }
};

ENTRY_IMPLEMENT_MAIN(ExampleHelloWorld);

when i try to run the project i get this error:

/usr/bin/ld: thirdparty/bgfx.cmake/libbgfxd.a(glcontext_glx.cpp.o): undefined reference to symbol 'XFree'

//usr/lib/x86_64-linux-gnu/libX11.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

as i wrote: i'm pretty sure i did something wrong, but i rly can't figure out what.
So maybe someone can push me into the right direction.

Amalgamated builds cause linking errors with tools.

Tools use CMake interface library to include some files from bgfx sources. When using amalgamated build these sources are marked as headers and therefore not complied nor linked.

This can be solved by createing cpp file in binary directory that include necessary file there.

Changing header only flag to false in tool cmake file may not work due to how cmake works.

Thanks for your work. : )

CC0 license

It's quite unusual to have a CC0 license for source code. Is there any reason not to use a more typical license like MIT, BSD, etc.?

shaderc_parse usage

Good day!
First of all, I want to say thank you. I really do enjoy cmake-based bgfx ^^

Okay, now lets go ahead to the question...

I have an project which uses bgfx.cmake:

cmake_minimum_required(VERSION 3.7)
project(SomeProject)

set(CMAKE_CXX_STANDARD 14)

file(GLOB JULIVI_SOURCE_FILES
    "src/*.h"
    "src/*.cpp"
)

add_subdirectory("deps/bgfx") 
add_executable(${PROJECT_NAME} ${JULIVI_SOURCE_FILES})
target_compile_definitions(${PROJECT_NAME} PRIVATE ENTRY_CONFIG_IMPLEMENT_MAIN=1 _CRT_SECURE_NO_WARNINGS=1)

target_link_libraries(${PROJECT_NAME} bgfx example-common)

bgfx.cmake located in deps/bgfx

my question is: how to compile every shader from directory X and put binaries into directory Y? Preferably before every build, because the number of shaders can vary

P.S. I tired something like shaderc_parse("shaders/vs_test.sc" "asset/vs_test.bin" VERTEX WINDOWS), but it feels like nothing is happening (no cmake errors here)

Add DEBUG_POSTFIX to CMakeLists.txt files

Hey there!

First off this repo is excellent and has made my life a lot easier getting setup with bgfx - thank you very much for creating it!

One suggestion I have would be to add the DEBUG_POSTFIX option supported by CMake to either the root CMakeLists.txt file or more granularly to each target in the .cmake files.

It can be set globally:

set(SDL_CMAKE_DEBUG_POSTFIX "d"
    CACHE STRING "Name suffix for debug builds")

or per target:

set_target_properties(
    ${PROJECT_NAME} PROPERTIES DEBUG_POSTFIX "d")

It's incredibly useful when installing libraries as they can be installed to the same folder without overwriting whichever version was there first (e.g. if you build Debug and install, and then build Release and install, the Release .lib/dll files will override the debug ones). You can work around this by creating two separate install locations but then it makes the life of the consuming library/application more difficult.

I'd be interested to hear what you think, I've written up a little more information about it here in the past: https://github.com/pr0g/cmake-examples#debug_postfix

Thanks!

Tom

Build error with glslang

In my CMakeLists.txt:

# bgfx
set(BGFX_BUILD_EXAMPLES OFF)
set(BGFX_INSTALL_EXAMPLES OFF)
set(BGFX_INSTALL OFF)
add_subdirectory("${DEPS_DIR}/bgfx.cmake")

I get the following compilation error on Windows (VS 2019):

bgfx.cmake\bgfx\3rdparty\glslang\SPIRV\GlslangToSpv.cpp(61,10): fatal error C1083: Cannot open include file: 'glslang/build_info.h': No such file or directory

Disabling examples breaks build

Howdy!

Looks like texturev depend on common.h in bgfx/examples/common. When you configure the project without examples the path is no longer part of the included header search paths.

C:\projects\bgfx.cmake\.build>cmake -GNinja ..-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
.....<snip>....
C:\projects\bgfx.cmake\.build>rg texturev.cpp compile_commands.json
82:  "command": "C:\\PROGRA~2\\MICROS~3\\2017\\COMMUN~1\\VC\\Tools\\MSVC\\1411~1.255\\bin\\HostX64\\x64\\cl.exe  /nologo /TP -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I..\\bgfx\\examples\\common -I..\\bgfx\\include -I..\\bx\\include -I..\\bx\\include\\compat\\msvc -I..\\bimg\\include -I..\\bimg\\3rdparty -I..\\bimg\\3rdparty\\iqa\\include -I..\\bimg\\3rdparty\\nvtt -I..\\bgfx\\3rdparty  /DWIN32 /D_WINDOWS /W3 /GR /EHsc /MDd /Zi /Ob0 /Od /RTC1   /FoCMakeFiles\\texturev.dir\\bgfx\\tools\\texturev\\texturev.cpp.obj /FdTARGET_COMPILE_PDB /FS -c C:\\projects\\bgfx.cmake\\bgfx\\tools\\texturev\\texturev.cpp",
83:  "file": "C:/projects/bgfx.cmake/bgfx/tools/texturev/texturev.cpp"

C:\projects\bgfx.cmake\.build>cmake -GNinja .. -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DBGFX_BUILD_EXAMPLES=OFF
-- Configuring done
-- Generating done
-- Build files have been written to: C:/projects/bgfx.cmake/.build

C:\projects\bgfx.cmake\.build>rg texturev.cpp compile_commands.json
58:  "command": "C:\\PROGRA~2\\MICROS~3\\2017\\COMMUN~1\\VC\\Tools\\MSVC\\1411~1.255\\bin\\HostX64\\x64\\cl.exe  /nologo /TP   /DWIN32 /D_WINDOWS /W3 /GR /EHsc /MDd /Zi /Ob0 /Od /RTC1   /FoCMakeFiles\\texturev.dir\\bgfx\\tools\\texturev\\texturev.cpp.obj /FdTARGET_COMPILE_PDB /FS -c C:\\projects\\bgfx.cmake\\bgfx\\tools\\texturev\\texturev.cpp",
59:  "file": "C:/projects/bgfx.cmake/bgfx/tools/texturev/texturev.cpp"

Installing on a system has conflicts for binaries such as shaderc

Not sure where to file this.

I'm now maintaining a packaging of this project for the AUR with the fixes in #100 and #101.
One of the issues I ran into is that the tool binaries have names that can cause conflicts with other projects, see https://www.github.com/google/shaderc

My current solution is to prepend bgfx- to the tool filenames see https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=bgfx-cmake-git#n51

Would anyone be interested if I upstreamed this change behind an option maybe?

shared lib

Hello,
do You have any advices for building bgfx as a shared library? I did something like this:

ExternalProject_Add(
    bgfx
    CMAKE_ARGS
    "-DBUILD_SHARED_LIBS=1"
    "-DCMAKE_POSITION_INDEPENDENT_CODE=1"
    ...
)

but it causes shaderc and other tools to be built with dynamic dependences which I would like to avoid. Currently I'm hacking it around setting BUILD_SHARED_LIBS=0 in the sharderc.cmake. Do you know any cleaner and more elegant solution?

Install w/ Examples

Hello,

First off, thank you for putting this together. I was in the middle of creating my own about a year ago and lost track of time and just started coming back to it. On a whim I searched to see if anyone else had already done it and here we are! You managed to do far more than I could though - I'm not very well versed with CMake.

I think it would be helpful if you are building examples that INSTALL also created an examples folder in the install location with all the files necessary to run each example.

VS 2017 compile error, bimg header not found

I imported this to my project with

add_subdirectory(bgfx.cmake)

And I'm getting this when trying to build:

11>image.cpp
11>D:\Nikos\Programming\cpp\pctation\external\bgfx.cmake\bimg\src\image.cpp(9): fatal error C1083: Cannot open include file: 'astc-codec/astc-codec.h': No such file or directory

no errors on CMake configure.

Generator is Visual Studio 15 2017 Win64, project files generated with cmake-gui.

The file exists and it's in bgfx.cmake\bimg\3rdparty\astc-codec\include\astc-codec, but that directory is not present in the bimg project's include dirs. Putting it manually in bimg Property Pages works, but of course that's not really a solution, CMake should handle this.

Also, after doing the above hack, linking fails because ASTCDecompressToRGBA which is defined in the above file is unresolved.

I'd appreciate any help, thanks.

OpenGL/ES renderer version

A recent commit introduced the use of MIN_VERSION flags, which don't seem to be used in the BGFX source. What is the purpose and impact of this change ?

some generated shaders need to be embedded using bin2c

./examples/02-metaballs/fs_metaballs.bin.h
./examples/02-metaballs/vs_metaballs.bin.h
./examples/17-drawstress/fs_drawstress.bin.h
./examples/17-drawstress/vs_drawstress.bin.h
./examples/common/debugdraw/fs_debugdraw_fill.bin.h
./examples/common/debugdraw/fs_debugdraw_fill_lit.bin.h
./examples/common/debugdraw/fs_debugdraw_fill_texture.bin.h
./examples/common/debugdraw/fs_debugdraw_lines.bin.h
./examples/common/debugdraw/fs_debugdraw_lines_stipple.bin.h
./examples/common/debugdraw/vs_debugdraw_fill.bin.h
./examples/common/debugdraw/vs_debugdraw_fill_lit.bin.h
./examples/common/debugdraw/vs_debugdraw_fill_lit_mesh.bin.h
./examples/common/debugdraw/vs_debugdraw_fill_mesh.bin.h
./examples/common/debugdraw/vs_debugdraw_fill_texture.bin.h
./examples/common/debugdraw/vs_debugdraw_lines.bin.h
./examples/common/debugdraw/vs_debugdraw_lines_stipple.bin.h
./examples/common/font/fs_font_basic.bin.h
./examples/common/font/fs_font_distance_field.bin.h
./examples/common/font/fs_font_distance_field_subpixel.bin.h
./examples/common/font/vs_font_basic.bin.h
./examples/common/font/vs_font_distance_field.bin.h
./examples/common/font/vs_font_distance_field_subpixel.bin.h
./examples/common/imgui/fs_imgui_color.bin.h
./examples/common/imgui/fs_imgui_cubemap.bin.h
./examples/common/imgui/fs_imgui_image.bin.h
./examples/common/imgui/fs_imgui_image_swizz.bin.h
./examples/common/imgui/fs_imgui_latlong.bin.h
./examples/common/imgui/fs_imgui_texture.bin.h
./examples/common/imgui/fs_ocornut_imgui.bin.h
./examples/common/imgui/vs_imgui_color.bin.h
./examples/common/imgui/vs_imgui_cubemap.bin.h
./examples/common/imgui/vs_imgui_image.bin.h
./examples/common/imgui/vs_imgui_latlong.bin.h
./examples/common/imgui/vs_imgui_texture.bin.h
./examples/common/imgui/vs_ocornut_imgui.bin.h
./examples/common/nanovg/fs_nanovg_fill.bin.h
./examples/common/nanovg/vs_nanovg_fill.bin.h
./examples/common/ps/fs_particle.bin.h
./examples/common/ps/vs_particle.bin.h
./src/fs_clear0.bin.h
./src/fs_clear1.bin.h
./src/fs_clear2.bin.h
./src/fs_clear3.bin.h
./src/fs_clear4.bin.h
./src/fs_clear5.bin.h
./src/fs_clear6.bin.h
./src/fs_clear7.bin.h
./src/fs_debugfont.bin.h
./src/vs_clear.bin.h
./src/vs_debugfont.bin.h
./tools/texturev/fs_texture_3d.bin.h
./tools/texturev/fs_texture_array.bin.h
./tools/texturev/fs_texture.bin.h
./tools/texturev/fs_texture_cube2.bin.h
./tools/texturev/fs_texture_cube.bin.h
./tools/texturev/fs_texture_msdf.bin.h
./tools/texturev/fs_texture_sdf.bin.h
./tools/texturev/vs_texture.bin.h
./tools/texturev/vs_texture_cube.bin.h

currently done using this makefile

examples/02-metaballs/makefile:include ../../scripts/shader-embeded.mk
examples/17-drawstress/makefile:include ../../scripts/shader-embeded.mk
examples/common/debugdraw/makefile:include ../../../../bgfx/scripts/shader-embeded.mk
examples/common/font/makefile:include ../../../scripts/shader-embeded.mk
examples/common/imgui/makefile:include ../../../scripts/shader-embeded.mk
examples/common/nanovg/makefile:include ../../../scripts/shader-embeded.mk
examples/common/ps/makefile:include ../../../../bgfx/scripts/shader-embeded.mk
tools/texturev/makefile:include ../../../bgfx/scripts/shader-embeded.mk

mingw under macOS: build errors

Hello Joshua,

I am using macOS 10.11.6, and mingw-w64 installed via the excellent 'brew' package manager.

My MINGW environment var is set to '/usr/local/Cellar/mingw-w64/5.0.1', which contains a bin/ directory that has links to all of the tools.

Compiling using bgfx.cmake I get the following compile-time errors:

In file included from /Volumes/data/mine/SciFiGameProjects/third_party/bx/src/amalgamated.cpp:10:0:
/Volumes/data/mine/SciFiGameProjects/third_party/bx/src/debug.cpp: In function ‘void bx::debugPrintfData(const void*, uint32_t, const char*, ...)’:
/Volumes/data/mine/SciFiGameProjects/third_party/bx/src/debug.cpp:93:25: error: expected ‘)’ before ‘PRIxPTR’
#define DBG_ADDRESS "%" PRIxPTR
^
/Volumes/data/mine/SciFiGameProjects/third_party/bx/src/debug.cpp:106:26: note: in expansion of macro ‘DBG_ADDRESS’
debugPrintf("\ndata: " DBG_ADDRESS ", size: %d\n", _data, _size);
^~~~~~~~~~~
/Volumes/data/mine/SciFiGameProjects/third_party/bx/src/debug.cpp:93:25: error: expected ‘)’ before ‘PRIxPTR’
#define DBG_ADDRESS "%" PRIxPTR
^
/Volumes/data/mine/SciFiGameProjects/third_party/bx/src/debug.cpp:126:23: note: in expansion of macro ‘DBG_ADDRESS’
debugPrintf("\t" DBG_ADDRESS "\t" HEX_DUMP_FORMAT "\t%s\n", data, hex, ascii);
^~~~~~~~~~~
/Volumes/data/mine/SciFiGameProjects/third_party/bx/src/debug.cpp:93:25: error: expected ‘)’ before ‘PRIxPTR’
#define DBG_ADDRESS "%" PRIxPTR
^
/Volumes/data/mine/SciFiGameProjects/third_party/bx/src/debug.cpp:136:22: note: in expansion of macro ‘DBG_ADDRESS’
debugPrintf("\t" DBG_ADDRESS "\t" HEX_DUMP_FORMAT "\t%s\n", data, hex, ascii);
^~~~~~~~~~~

Note that my first order of business was to try this under bgfx's "native" GENie build system, in case the code base itself had trouble supporting this (somewhat obtuse?) build environment. The GENie build does have a problem (and I've filed an Issue), but GENie makes it to link stage, so it does not have this particular issue.

Notes:

  1. The problem is that PRIxPTR is not defined (problem disappears when I throw the def in the file).
  2. The macro definition of PRIxPTR should be in inttypes.h, but only the C99 version (not C++).
  3. I have ./toolchain-x86_64/x86_64-w64-mingw32/include/inttypes.h in my environment, the C version that has this definition (confirmed).
  4. I also have a C++ file version: ./toolchain-x86_64/x86_64-w64-mingw32/include/c++/6.3.0/tr1/inttypes.h. This file does not have the definition (not C99 conformant).
  5. The target file (debug.cpp) is a C++ file. I do not know why this should (or shouldn't) work, but it seems to fail under MINGW on macOS.

I also had a problem with linking, which might manifest for MINGW targets on linux & macOS (any cross compile).

To correct the first problem on my end, I did a very hacky thing: copied definitions from mingw headers to cmake -D defines. You probably don't want to do that, but here a patch of my changes:

diff --git a/cmake/bx.cmake b/cmake/bx.cmake
index b5204b6..304908d 100644
--- a/cmake/bx.cmake
+++ b/cmake/bx.cmake
@@ -21,7 +21,7 @@ file( GLOB BX_SOURCES ${BX_DIR}/src/*.cpp )
 add_library( bx STATIC ${BX_SOURCES} )

 # Link against psapi in Visual Studio
-if( MSVC )
+if( MSVC OR MINGW )
        target_link_libraries( bx PUBLIC psapi )
 endif()

@@ -33,6 +33,10 @@ if( MSVC )
        target_include_directories( bx PUBLIC ${BX_DIR}/include/compat/msvc )
        target_compile_definitions( bx PUBLIC "__STDC_FORMAT_MACROS" )
 elseif( MINGW )
+       add_definitions(-DPRIxPTR=\"I64x\")
+       add_definitions(-DPRIx64=\"I64x\")
+       add_definitions(-DPRIi64=\"I64i\")
+       add_definitions(-DPRId64=\"I64d\")
        target_include_directories( bx PUBLIC ${BX_DIR}/include/compat/mingw )
 elseif( APPLE )
        target_include_directories( bx PUBLIC ${BX_DIR}/include/compat/osx )

Hopefully this is instructive on the problem. With this patch (and after linking the project to C & C++ libs statically), everything is honky dory for bgfx, bx, & my project. GENie's problem is presently unresolved, but I can use bgfx.cmake to complete builds in this environment.

I can also use wine to run my project & tests. So thanks to cmake's cross compilation support, I can build & run all of my targets (macOS, iOS, Win32, Android) on macOS!

can't find example binary files

Hi,
I build whole project using cmake on ubuntu 16.04, but where can I find the example binary files? I just find geometryc shaderc texturec texturev binary files in the build folder.
Please help me.
Thanks.

WebGPU update

Recently, there has been a 3rdparty addition for bgfx.
This requires adding a cmake file for 3rdparty/webgpu and linking it properly.

examples excluded from the 'all' target by default

Why are you doing this?

if( BGFX_INSTALL_EXAMPLES )
	add_executable( example-${ARG_NAME} WIN32 ${SOURCES} )
else()
	add_executable( example-${ARG_NAME} WIN32 EXCLUDE_FROM_ALL ${SOURCES} )
endif()

It's not a bid deal, I can always do -DBGFX_INSTALL_EXAMPLES=ON when I generate, but I'm just trying to understand what you were trying to do. I personally don't care about the install target, but I want to test some changes I do to bgfx on some of those examples to make sure I didn't break anything...

Android support

So, how things going with android support?

Can I somehow help with it?

android support

will u please add android cmake support ?
i try to do this ,but faild.
u can test with android studio, with
simulator.

New fork info...

Due inactivity on PRs here, I made fork so that users can contribute updates faster:
https://github.com/bkaradzic/bgfx.cmake

It became one of major issues because a lot of people who choose to use CMake don't really know how to use it, and rely 100% on updates from this repo.

If you're interested I could add you as contributor? There are already some major changes in comparison with original repo, like switching from Travis to GitHub CI, adding ability to auto upgrade repo once bgfx/bimg/bx are updated, etc.

Freebsd compile problem

when runnig make freebsd
../bx/tools/bin/bsd/genie --with-tools --with-combined-examples --with-shared-lib --gcc=freebsd gmake
gmake: ../bx/tools/bin/bsd/genie: No such file or directory
gmake: *** [makefile:113: .build/projects/gmake-freebsd] Error 127
seems some files are missing!

Fix iOS and Android builds

Currently on travis, the iOS and Android builds are failing.
These should be fixed and their tests should be re-enabled.

  • Android is failing because sdkmanager cannot find lldb 3.1 Error: Failed to find package lldb;3.1
  • iOS is failing because it cannot find a Quartz Core header: fatal error: 'QuartzCore/CAMetalLayer.h' file not found

Shader includes (bgfx_shader.sh...) not copied on install

When using shaderc normally you would include bgfx_shader.sh or bgfx_compute.sh, these are located in bgfx/src.
When the library is installed these files disappear, removing the ability to use shaderc effectively.

A possible solution I can think of is to copy src/bgfx_shader.sh -> $INSTALL_TARGET/include/bgfx_shader.sh - but I'm not sure how good this would be.

Windows compile error

I've got an error when I was trying to compile bgfx in Windows. This is the following error:

C:\Users\rauls\AppData\Local\JetBrains\Toolbox\apps\CLion\ch-0\172.3544.40\bin\cmake\bin\cmake.exe --build C:\Users\rauls\CLionProjects\Litecraft\cmake-build-debug --target litecraft -- -j 2
[  6%] Built target pvrtc
[ 20%] Built target bx
[ 26%] Built target squish
[ 33%] Built target edtaa3
[ 33%] Built target etc1
[ 33%] Built target Boost_system
[ 40%] Built target iqa
[ 53%] Built target nvtt
[ 53%] Built target etc2
[ 53%] Built target ib-compress
[ 53%] Built target ocornut-imgui
[ 53%] Built target bimg
[ 60%] Built target Boost_filesystem
[ 60%] Building CXX object bgfx/CMakeFiles/bgfx.dir/bgfx/src/renderer_d3d11.cpp.obj
[ 60%] Building CXX object bgfx/CMakeFiles/bgfx.dir/bgfx/src/renderer_d3d12.cpp.obj
In file included from C:\Users\rauls\CLionProjects\Litecraft\bgfx\bgfx\src\renderer_d3d12.h:15:0,
                 from C:\Users\rauls\CLionProjects\Litecraft\bgfx\bgfx\src\renderer_d3d12.cpp:9:
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d12.h:946:56: error: expected constructor, destructor, or type conversion before ';' token
 DEFINE_ENUM_FLAG_OPERATORS( D3D12_COMMAND_QUEUE_FLAGS );
                                                        ^
In file included from C:\Users\rauls\CLionProjects\Litecraft\bgfx\bgfx\src\renderer_d3d12.h:15:0,
                 from C:\Users\rauls\CLionProjects\Litecraft\bgfx\bgfx\src\renderer_d3d12.cpp:9:
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d12.h:1598:57: error: expected constructor, destructor, or type conversion before ';' token
 DEFINE_ENUM_FLAG_OPERATORS( D3D12_PIPELINE_STATE_FLAGS );
                                                         ^
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d12.h:1653:65: error: expected constructor, destructor, or type conversion before ';' token
 DEFINE_ENUM_FLAG_OPERATORS( D3D12_SHADER_MIN_PRECISION_SUPPORT );
                                                                 ^
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d12.h:1715:52: error: expected constructor, destructor, or type conversion before ';' token
 DEFINE_ENUM_FLAG_OPERATORS( D3D12_FORMAT_SUPPORT1 );
                                                    ^
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d12.h:1733:52: error: expected constructor, destructor, or type conversion before ';' token
 DEFINE_ENUM_FLAG_OPERATORS( D3D12_FORMAT_SUPPORT2 );
                                                    ^
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d12.h:1741:68: error: expected constructor, destructor, or type conversion before ';' token
 DEFINE_ENUM_FLAG_OPERATORS( D3D12_MULTISAMPLE_QUALITY_LEVEL_FLAGS );
                                                                    ^
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d12.h:1876:47: error: expected constructor, destructor, or type conversion before ';' token
 DEFINE_ENUM_FLAG_OPERATORS( D3D12_HEAP_FLAGS );
                                               ^
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d12.h:1916:51: error: expected constructor, destructor, or type conversion before ';' token
 DEFINE_ENUM_FLAG_OPERATORS( D3D12_RESOURCE_FLAGS );
                                                   ^
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d12.h:2016:55: error: expected constructor, destructor, or type conversion before ';' token
 DEFINE_ENUM_FLAG_OPERATORS( D3D12_TILE_MAPPING_FLAGS );
                                                       ^
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d12.h:2026:52: error: expected constructor, destructor, or type conversion before ';' token
 DEFINE_ENUM_FLAG_OPERATORS( D3D12_TILE_COPY_FLAGS );
                                                    ^
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d12.h:2050:52: error: expected constructor, destructor, or type conversion before ';' token
 DEFINE_ENUM_FLAG_OPERATORS( D3D12_RESOURCE_STATES );
                                                    ^
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d12.h:2087:59: error: expected constructor, destructor, or type conversion before ';' token
 DEFINE_ENUM_FLAG_OPERATORS( D3D12_RESOURCE_BARRIER_FLAGS );
                                                           ^
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d12.h:2161:53: error: expected constructor, destructor, or type conversion before ';' token
 DEFINE_ENUM_FLAG_OPERATORS( D3D12_BUFFER_SRV_FLAGS );
                                                     ^
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d12.h:2414:53: error: expected constructor, destructor, or type conversion before ';' token
 DEFINE_ENUM_FLAG_OPERATORS( D3D12_BUFFER_UAV_FLAGS );
                                                     ^
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d12.h:2608:46: error: expected constructor, destructor, or type conversion before ';' token
 DEFINE_ENUM_FLAG_OPERATORS( D3D12_DSV_FLAGS );
                                              ^
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d12.h:2644:48: error: expected constructor, destructor, or type conversion before ';' token
 DEFINE_ENUM_FLAG_OPERATORS( D3D12_CLEAR_FLAGS );
                                                ^
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d12.h:2653:48: error: expected constructor, destructor, or type conversion before ';' token
 DEFINE_ENUM_FLAG_OPERATORS( D3D12_FENCE_FLAGS );
                                                ^
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d12.h:2671:58: error: expected constructor, destructor, or type conversion before ';' token
 DEFINE_ENUM_FLAG_OPERATORS( D3D12_DESCRIPTOR_HEAP_FLAGS );
                                                          ^
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d12.h:2763:57: error: expected constructor, destructor, or type conversion before ';' token
 DEFINE_ENUM_FLAG_OPERATORS( D3D12_ROOT_SIGNATURE_FLAGS );
                                                         ^
In file included from C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d12.h:6189:0,
                 from C:\Users\rauls\CLionProjects\Litecraft\bgfx\bgfx\src\renderer_d3d12.h:15,
                 from C:\Users\rauls\CLionProjects\Litecraft\bgfx\bgfx\src\renderer_d3d12.cpp:9:
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d12sdklayers.h:187:50: error: expected constructor, destructor, or type conversion before ';' token
 DEFINE_ENUM_FLAG_OPERATORS( D3D12_DEBUG_FEATURE );
                                                  ^
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d12sdklayers.h:200:1: error: expected constructor, destructor, or type conversion before 'extern'
 extern RPC_IF_HANDLE __MIDL_itf_d3d12sdklayers_0000_0001_v0_0_c_ifspec;
 ^~~~~~
In file included from C:\Users\rauls\CLionProjects\Litecraft\bgfx\bgfx\src\renderer_d3d12.h:37:0,
                 from C:\Users\rauls\CLionProjects\Litecraft\bgfx\bgfx\src\renderer_d3d12.cpp:9:
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3dx12.h: In function 'UINT64 GetRequiredIntermediateSize(ID3D12Resource*, UINT, UINT)':
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3dx12.h:1359:58: error: expected primary-expression before ')' token
     pDestinationResource->GetDevice(__uuidof(ID3D12Device), reinterpret_cast<void**>(&pDevice));
                                                          ^
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3dx12.h:1359:58: error: '__uuidof' was not declared in this scope
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3dx12.h: In function 'UINT64 UpdateSubresources(ID3D12GraphicsCommandList*, ID3D12Resource*, ID3D12Resource*, UINT64, UINT, UINT, D3D12_SUBRESOURCE_DATA*)':
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3dx12.h:1453:58: error: expected primary-expression before ')' token
     pDestinationResource->GetDevice(__uuidof(ID3D12Device), reinterpret_cast<void**>(&pDevice));
                                                          ^
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3dx12.h:1453:58: error: '__uuidof' was not declared in this scope
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3dx12.h: In function 'UINT64 UpdateSubresources(ID3D12GraphicsCommandList*, ID3D12Resource*, ID3D12Resource*, UINT64, UINT, UINT, D3D12_SUBRESOURCE_DATA*)':
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3dx12.h:1481:54: error: there are no arguments to '__uuidof' that depend on a template parameter, so a declaration of '__uuidof' must be available [-fpermissive]
     pDestinationResource->GetDevice(__uuidof(*pDevice), reinterpret_cast<void**>(&pDevice));
                                                      ^
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3dx12.h:1481:54: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
In file included from C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d11.h:14382:0,
                 from C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d11_1.h:127,
                 from C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d11_2.h:66,
                 from C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d11_3.h:115,
                 from C:\Users\rauls\CLionProjects\Litecraft\bgfx\bgfx\src\renderer_d3d11.h:23,
                 from C:\Users\rauls\CLionProjects\Litecraft\bgfx\bgfx\src\renderer_d3d11.cpp:9:
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d11sdklayers.h:129:1: error: expected constructor, destructor, or type conversion before 'extern'
 extern RPC_IF_HANDLE __MIDL_itf_d3d11sdklayers_0000_0000_v0_0_c_ifspec;
 ^~~~~~
C:\Users\rauls\CLionProjects\Litecraft\bgfx\bgfx\src\renderer_d3d12.cpp: In member function 'void bgfx::d3d12::TextureD3D12::create(const bgfx::Memory*, uint32_t, uint8_t)':
C:\Users\rauls\CLionProjects\Litecraft\bgfx\bgfx\src\renderer_d3d12.cpp:4213:27: error: invalid conversion from 'int' to 'D3D12_RESOURCE_FLAGS' [-fpermissive]
     resourceDesc.Flags |= D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL;
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\rauls\CLionProjects\Litecraft\bgfx\bgfx\src\renderer_d3d12.cpp:4214:27: error: invalid conversion from 'int' to 'D3D12_RESOURCE_STATES' [-fpermissive]
     state              |= D3D12_RESOURCE_STATE_DEPTH_WRITE;
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\rauls\CLionProjects\Litecraft\bgfx\bgfx\src\renderer_d3d12.cpp:4215:28: error: invalid conversion from 'int' to 'D3D12_RESOURCE_STATES' [-fpermissive]
     state              &= ~D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE;
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\rauls\CLionProjects\Litecraft\bgfx\bgfx\src\renderer_d3d12.cpp:4231:27: error: invalid conversion from 'int' to 'D3D12_RESOURCE_FLAGS' [-fpermissive]
     resourceDesc.Flags |= D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET;
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\rauls\CLionProjects\Litecraft\bgfx\bgfx\src\renderer_d3d12.cpp:4236:27: error: invalid conversion from 'int' to 'D3D12_RESOURCE_FLAGS' [-fpermissive]
     resourceDesc.Flags |= D3D12_RESOURCE_FLAG_DENY_SHADER_RESOURCE;
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\rauls\CLionProjects\Litecraft\bgfx\bgfx\src\renderer_d3d12.cpp:4237:28: error: invalid conversion from 'int' to 'D3D12_RESOURCE_STATES' [-fpermissive]
     state              &= ~D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE;
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\rauls\CLionProjects\Litecraft\bgfx\bgfx\src\renderer_d3d12.cpp:4242:27: error: invalid conversion from 'int' to 'D3D12_RESOURCE_FLAGS' [-fpermissive]
     resourceDesc.Flags |= D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS;
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mingw32-make.exe[3]: *** [bgfx/CMakeFiles/bgfx.dir/bgfx/src/renderer_d3d12.cpp.obj] Error 1
bgfx\CMakeFiles\bgfx.dir\build.make:262: recipe for target 'bgfx/CMakeFiles/bgfx.dir/bgfx/src/renderer_d3d12.cpp.obj' failed
mingw32-make.exe[3]: *** Waiting for unfinished jobs....
mingw32-make.exe[3]: *** [bgfx/CMakeFiles/bgfx.dir/bgfx/src/renderer_d3d11.cpp.obj] Error 1
bgfx\CMakeFiles\bgfx.dir\build.make:237: recipe for target 'bgfx/CMakeFiles/bgfx.dir/bgfx/src/renderer_d3d11.cpp.obj' failed
mingw32-make.exe[2]: *** [bgfx/CMakeFiles/bgfx.dir/all] Error 2
CMakeFiles\Makefile2:1073: recipe for target 'bgfx/CMakeFiles/bgfx.dir/all' failed
CMakeFiles\Makefile2:3628: recipe for target 'src/CMakeFiles/litecraft.dir/rule' failed
mingw32-make.exe[1]: *** [src/CMakeFiles/litecraft.dir/rule] Error 2
Makefile:1268: recipe for target 'litecraft' failed
mingw32-make.exe: *** [litecraft] Error 2

I tried also to compile it with the examples, but the same error occur.

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.