Browse Source

add option to build a recent version of assimp

fixes bug on fedora 33 where the default assimp version doesn't support
glTF2
render_group_fix
cinnaboot 5 years ago
parent
commit
787234c969
  1. 29
      Makefile
  2. 31
      README.txt
  3. 6
      examples/Makefile
  4. 5
      src/renderer.cpp

29
Makefile

@ -1,6 +1,10 @@
SHELL = /bin/sh
CXX = g++ CXX = g++
CXXFLAGS = -std=c++11 -g -ggdb3 -Wall -Iinclude -I/usr/include/SDL2 -Iext/stb_libs CXXFLAGS = -std=c++11 -g -ggdb3 -Wall \
-Iinclude \
-I/usr/include/SDL2 \
-Iext/stb_libs
EXAMPLEDIR = examples EXAMPLEDIR = examples
OBJDIR = build OBJDIR = build
SRCDIR = src SRCDIR = src
@ -9,14 +13,33 @@ LIBNAME = libTangerine.a
RENDER_SOURCES = $(wildcard $(SRCDIR)/*.cpp) RENDER_SOURCES = $(wildcard $(SRCDIR)/*.cpp)
RENDER_OBJECTS = $(patsubst $(SRCDIR)/%.cpp, $(OBJDIR)/%.o, $(RENDER_SOURCES)) RENDER_OBJECTS = $(patsubst $(SRCDIR)/%.cpp, $(OBJDIR)/%.o, $(RENDER_SOURCES))
ASSIMP_DIR=ext/assimp
ifeq ($(USE_INTERNAL_ASSIMP), y)
$(info using internal assimp)
CXXFLAGS += -I$(ASSIMP_DIR)/include
endif
all: mkdirs $(LIBNAME) examples all: mkdirs $(LIBNAME) examples
.PHONY: all .PHONY: all
-include $(OBJDIR)/*.d -include $(OBJDIR)/*.d
# NOTE: target to automatically build a current release of assimp. Fixes
# issue on Fedora where the default assimp version doesn't support glTF2
build_assimp:
if [ ! -d $(ASSIMP_DIR) ]; then \
git clone -n "https://github.com/assimp/assimp" $(ASSIMP_DIR); \
cd $(ASSIMP_DIR); \
git checkout -q v5.0.1; \
fi
cmake -S $(ASSIMP_DIR) -B $(ASSIMP_DIR)
$(MAKE) -C $(ASSIMP_DIR)
.PHONY: build_assimp
mkdirs: mkdirs:
mkdir -p $(OBJDIR) @mkdir -p $(OBJDIR)
.PHONY: mkdirs .PHONY: mkdirs
$(LIBNAME): $(RENDER_OBJECTS) $(LIBNAME): $(RENDER_OBJECTS)
@ -26,7 +49,7 @@ $(RENDER_OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.cpp
$(CXX) $(CXXFLAGS) -c -MMD $< -o $@ $(CXX) $(CXXFLAGS) -c -MMD $< -o $@
examples: $(LIBNAME) examples: $(LIBNAME)
$(MAKE) -C $(EXAMPLEDIR) ASSIMP_DIR=$(ASSIMP_DIR) $(MAKE) -C $(EXAMPLEDIR)
.PHONY: examples .PHONY: examples
clean: clean:

31
README.txt

@ -15,8 +15,37 @@ TODO:
add a function to update camera transforms only once per frame, per shader add a function to update camera transforms only once per frame, per shader
Dependencies: Dependencies:
assimp assimp >= 5.0.0
glew glew
glm glm
SDL2 SDL2
stb_image stb_image
Build Instructions:
install dependencies:
Arch)
$ sudo pacman -S assimp glew glm sd2 catch2 gcc make
Fedora)
NOTE: Fedora (33) ships with assimp v3.3.1 which doesn't support
glTF2: https://en.wikipedia.org/wiki/GlTF
$ sudo dnf install glew-devel glm-devel catch-devel SDL2-devel \
gcc-c++ make cmake
checkout, and initialize submodules: (stb_image)
$ git submodule init
$ git submodule update
(optional) checkout large files for running examples:
(NOTE: https://git-lfs.github.com/)
$ git lfs pull
build:
$ make
NOTE: if build fails with errors from assimp or mesh.cpp, you can build
a recent version of assimp first. Requires cmake
$ make build_assimp && USE_INTERNAL_ASSIMP=y make
to run examples without installing assimp as a system library:
$ cd examples/bin
$ LD_LIBRARY_PATH=../../ext/assimp/bin ./assimp_loading

6
examples/Makefile

@ -1,4 +1,5 @@
SHELL = /bin/sh
CXX = g++ CXX = g++
CXXFLAGS = -std=c++11 -g -ggdb3 -Wall -I../include -I/usr/include/SDL2 CXXFLAGS = -std=c++11 -g -ggdb3 -Wall -I../include -I/usr/include/SDL2
LDFLAGS = -lSDL2 -lGLEW -lGL -lassimp LDFLAGS = -lSDL2 -lGLEW -lGL -lassimp
@ -6,6 +7,11 @@ OBJDIR = build
LIB = ../build/libTangerine.a LIB = ../build/libTangerine.a
BINDIR = bin BINDIR = bin
ifeq ($(USE_INTERNAL_ASSIMP), y)
CXXFLAGS += -I../$(ASSIMP_DIR)/include
LDFLAGS = -lSDL2 -lGLEW -lGL -L../$(ASSIMP_DIR)/bin -lassimp
endif
all: mkdirs \ all: mkdirs \
$(OBJDIR)/hello_world.o \ $(OBJDIR)/hello_world.o \

5
src/renderer.cpp

@ -201,10 +201,9 @@ initContext(SDL_Handles* handles)
return false; return false;
} }
if (SDL_GL_SetSwapInterval(1) != 0) { // vsync // TODO: this doesn't work inside VM with QXL graphics
if (SDL_GL_SetSwapInterval(1) != 0) // vsync
LOG(Error) << "SDL Errors: " << SDL_GetError() << "\n"; LOG(Error) << "SDL Errors: " << SDL_GetError() << "\n";
return false;
}
return true; return true;
} }

Loading…
Cancel
Save