#!/bin/sh
# Copyright 2019 Ryan Pavlik
# SPDX-License-Identifier: Apache-2.0

set -e
# set -x

MYDIR=$(mktemp -d)
trap "rm -rf $MYDIR" EXIT

SRC=$(pwd)

cd $MYDIR
FLAGS="-DOS_LINUX_XLIB -I${SRC}/external/include"

# must compile gfxwrapper separately first with cc
cc -std=c99 ${FLAGS} -c ${SRC}/src/common/gfxwrapper_opengl.c -o gfxwrapper.o
c++ \
    -std=c++11 \
    ${FLAGS} \
    -I${SRC}/src \
    -I${SRC}/src/common \
    -I${SRC}/src/tests/hello_xr/vulkan_shaders \
    -DXR_USE_PLATFORM_XLIB \
    -DXR_USE_GRAPHICS_API_OPENGL \
    gfxwrapper.o \
    ${SRC}/src/tests/hello_xr/*.cpp \
    $(pkg-config --cflags --libs openxr gl x11 xxf86vm xrandr) \
    -o hello_xr

# ./hello_xr -g OpenGL
