bgfx with Ubuntu 16.04

make linux

Generating ../.build/projects/gmake-linux/geometryc.make...
Done. Generated 41/41 projects.
make -R -C .build/projects/gmake-linux config=debug32
make[1]: Entering directory '/home/lucasw/other/bgfx/.build/projects/gmake-linux'
==== Building bgfx (debug32) ====
Creating ../../linux32_gcc/obj/x32/Debug/bgfx
Creating ../../linux32_gcc/obj/x32/Debug/bgfx/src
bgfx.cpp
In file included from /usr/include/stdint.h:25:0,
                 from /usr/lib/gcc/x86_64-linux-gnu/5/include/stdint.h:9,
                 from ../../../include/bgfx/bgfx.h:10,
                 from ../../../src/bgfx_p.h:22,
                 from ../../../src/bgfx.cpp:13:
/usr/include/features.h:367:25: fatal error: sys/cdefs.h: No such file or directory
compilation terminated.
bgfx.make:413: recipe for target '../../linux32_gcc/obj/x32/Debug/bgfx/src/bgfx.o' failed
make[2]: *** [../../linux32_gcc/obj/x32/Debug/bgfx/src/bgfx.o] Error 1
Makefile:16: recipe for target 'bgfx' failed
make[1]: *** [bgfx] Error 2
make[1]: Leaving directory '/home/lucasw/other/bgfx/.build/projects/gmake-linux'
makefile:99: recipe for target 'linux-debug32' failed
make: *** [linux-debug32] Error 2
lucasw@L007:~/other/bgfx$ locate cdefs

I do have a cdefs.h in:

/usr/include/x86_64-linux-gnu/sys/cdefs.h

http://askubuntu.com/questions/470796/fatal-error-sys-cdefs-h-no-such-file-or-directory

sudo apt-get install g++-multilib

==== Building example-00-helloworld (debug32) ====
Creating ../../linux32_gcc/obj/x32/Debug/example-00-helloworld
Creating ../../linux32_gcc/obj/x32/Debug/example-00-helloworld/examples/00-helloworld
helloworld.cpp
Linking example-00-helloworld
/usr/bin/ld: cannot find -lX11
/usr/bin/ld: cannot find -lGL
collect2: error: ld returned 1 exit status
example-00-helloworld.make:246: recipe for target '../../linux32_gcc/bin/example-00-helloworldDebug' failed
make[2]: *** [../../linux32_gcc/bin/example-00-helloworldDebug] Error 1
Makefile:24: recipe for target 'example-00-helloworld' failed
make[1]: *** [example-00-helloworld] Error 2
make[1]: Leaving directory '/home/lucasw/other/bgfx/.build/projects/gmake-linux'
makefile:99: recipe for target 'linux-debug32' failed

Give up on make linux because it tries to make 32-bit, instead make linux-release64, linux-debug64

make -R -C .build/projects/gmake-linux config=release64
make[1]: Entering directory '/home/lucasw/other/bgfx/.build/projects/gmake-linux'
==== Building bgfx (release64) ====
Creating ../../linux64_gcc/obj/x64/Release/bgfx
Creating ../../linux64_gcc/obj/x64/Release/bgfx/src
bgfx.cpp
debug_renderdoc.cpp
glcontext_egl.cpp
glcontext_glx.cpp
glcontext_ppapi.cpp
glcontext_wgl.cpp
hmd.cpp
hmd_openvr.cpp
hmd_ovr.cpp
image.cpp
renderer_d3d11.cpp
renderer_d3d12.cpp
renderer_d3d9.cpp
renderer_gl.cpp
renderer_gnm.cpp
renderer_noop.cpp
...
avpcl_mode4.cpp
avpcl_mode5.cpp
avpcl_mode6.cpp
avpcl_mode7.cpp
avpcl_utils.cpp
fitting.cpp
nvtt.cpp
BitScale.cpp
MortonTable.cpp
PvrTcDecoder.cpp
PvrTcEncoder.cpp
PvrTcPacket.cpp
image.cpp
texturec.cpp
Linking texturec
==== Building texturev (release64) ====
Creating ../../linux64_gcc/obj/x64/Release/texturev
Creating ../../linux64_gcc/obj/x64/Release/texturev/tools/texturev
texturev.cpp
Linking texturev
Running post-build commands
Stripping symbols.
make[1]: Leaving directory '/home/lucasw/other/bgfx/.build/projects/gmake-linux'

bgfx/.build/linux64_gcc/bin$ ./example-01-cubesRelease
../../../examples/common/bgfx_utils.cpp(91): Failed to load shaders/glsl/vs_cubes.bin.
Segmentation fault (core dumped)

the shaders directory wasn’t copied into the .build dir, so

cd bgfx/examples/runtime
../../.build/linux64_gcc/bin/example-01-cubesRelease

07 locks up sometimes.

How to install bgfx?

Put everything in bgfx/.build/linux64_gcc/bin into a user lib location?

How to link a new project to bgfx?

Is there a way to build an example in verbose mode?

What include directory to include? Just copy bgfx/include into a findable location?

https://github.com/bkaradzic/bgfx/issues/612 shows that there is a bfgx.pc

Just going to point cmake straight at my custom build dir relative to $HOME.

bgfx minimal example

init is failing, try debugging

build the linux64 debug target, and link to that.

How to enable BX_TRACE?

I was missing the platform data.

entry_x11.cpp in the examples/common/entry shows what is missing.

But want to use entry_sdl instead.

What about entry_noop- does anything get rendered?

How to compile the examples to use sdl? I don’t see any sdl lib in the binaries. Need to supply –with-sdl to build process.

https://bkaradzic.github.io/bgfx/overview.html - sdl section.

SDL with ros? Just use find_package(SDL2)

shaderc

Live shader compiling

This doesn’t exist yet but there are multiple discussions in bgfx issues, and possible code to borrow if needed.

Command line that works for my linux system

~/other/bgfx/.build/linux64_gcc/bin/shadercDebug -f fs_cubes.sc -i $HOME/other/bgfx/src -o fs_cubes.bin --varyingdef ./varying.def.sc --platform linux --type fragment
~/other/bgfx/.build/linux64_gcc/bin/shadercDebug -f vs_cubes.sc -i $HOME/other/bgfx/src -o vs_cubes.bin --varyingdef ./varying.def.sc --platform linux --type vertex

updating

cd bx
git pull
cd ../bgfx
git pull
rm -rf .build
make linux-release64

vimrc

Syntax highlighting for sc (shader) files:

au BufNewFile,BufREad *.sc set filetype=cpp
Written on December 24, 2016