Reputation: 59
I'm having an issue building a project running bgfx with SDL2. I'm on Linux using X11.
Here's all the libraries I'm including:
#include <SDL.h>
#include <SDL_syswm.h>
#include <iostream>
#include <bgfx.h>
#include <bx/bx.h>
#include <bx/math.h>
Lines in my project which reference bx.h, in particular these ones:
const bx::Vec3 at = {0.0f, 0.0f, 0.0f};
const bx::Vec3 eye = {0.0f, 0.0f, -5.0f};
float view[16];
bx::mtxLookAt(view, eye, at);
float proj[16];
bx::mtxProj(proj, 60.0f, float(WINDOW_WIDTH) / float(WINDOW_HEIGHT), 0.1f, 100.0f, bgfx::getCaps()->homogeneousDepth);
Throw this error:
error: expected unqualified-id before numeric constant
I think I've worked out the root of the problem, but I have no clue if there's an elegant way to solve it. The problem I'm having ultimately comes from this block of code:
bgfx::PlatformData pd{};
#ifdef WIN32
pd.nwh = wmi.info.win.window;
printf("Windows")
#endif
#ifdef __apple__
pd.nwh = wmi.info.cocoa.window;
printf("MacOS");
#endif
#ifdef __linux__
pd.ndt = wmi.info.x11.display;
pd.nwh = (void *)(uintptr_t)wmi.info.x11.window;
printf("Linux");
#endif
This gets the window handle from SDL2 to be passed onto bgfx for rendering. This requires that I include SDL_syswm.h. If you go down the include chain with SDL_syswym, it includes X11/xlib.h, which then includes X11/x.h. This causes issues because X11/x.h contains this define statement:
#define None 0L
.
Any line which calls bx.h is causing errors because (I assume) x.h has None in a #define statement, which is conflicting with a separate definition of None which bx.h holds, as far as I can tell right here:
namespace init
{
/// Fields are left uninitialized.
///
struct NoneTag {};
constexpr NoneTag None;
/// Fields are initialized to zero.
///
struct ZeroTag {};
constexpr ZeroTag Zero;
/// Fields are initialized to identity value.
///
struct IdentityTag {};
constexpr IdentityTag Identity;
}
This definition is used across bx.h.
I'm considering just finding and switching to another maths library, but I'm not too familiar with C++ build systems, so if anyone has a suggestion as to another way that I could fix it, I'd be very open to them. I'm using CMake 3.0.0 and Make for builds.
Upvotes: 2
Views: 143