Browse Source

makefile, put compilation units in build directory

master
cinnaboot 8 years ago
parent
commit
fd6035a647
  1. 66
      Makefile
  2. 40
      src/Makefile
  3. 1
      src/hexgame.cpp
  4. 4
      src/mesh.h

66
Makefile

@ -0,0 +1,66 @@
CXX = g++
CXXFLAGS = -std=c++11 -g -ggdb -Wall
SRC_DIR = src
OBJ_DIR = build
# TODO: incorporate imgui into project files and not use gl3w
# can also remove -ldl from LDFLAGS then
CC = gcc
GL3W_CFLAGS = -Wall -I$(IMGUI_DIR)/examples/libs/gl3w
CXXFLAGS += -I$(IMGUI_DIR)/examples/libs/gl3w
GL3W_LDFLAGS += -ldl
# libGLEW needs to be >= 2.0.0 to use opengl core context
# don't know a good way to require this in make without forcing a specific version
LDFLAGS = -lSDL2 -lGLEW -lGL
# SDL2_image
CXXFLAGS += $(shell pkg-config --cflags SDL2_image)
LDFLAGS += $(shell pkg-config --libs SDL2_image)
# IMGUI
IMGUI_DIR = ext/imgui
CXXFLAGS += -I$(IMGUI_DIR) -I$(IMGUI_DIR)/examples/sdl_opengl3_example -I$(IMGUI_DIR)/examples/libs/gl3w
# assimp
LDFLAGS += -lassimp
SOURCES = $(IMGUI_DIR)/imgui.cpp \
$(IMGUI_DIR)/imgui_demo.cpp \
$(IMGUI_DIR)/imgui_draw.cpp \
$(IMGUI_DIR)/examples/sdl_opengl3_example/imgui_impl_sdl_gl3.cpp \
OBJECTS := $(patsubst %.cpp, $(OBJ_DIR)/%.o, $(notdir $(SOURCES)))
all: $(OBJECTS) $(OBJ_DIR)/gl3w.o
$(CXX) $(CXXFLAGS) -I/usr/include/SDL2 -Iext/aixlog/include -o $(OBJ_DIR)/hexgame $(SRC_DIR)/hexgame.cpp $(LDFLAGS) $(GL3W_LDFLAGS) $(OBJ_DIR)/*
mkdir -p bin
mv $(OBJ_DIR)/hexgame bin
info:
@echo "SOURCES:"
@echo $(SOURCES)
@echo "OBJECTS:"
@echo $(OBJECTS)
$(OBJ_DIR)/imgui.o:
$(CXX) -c $(CXXFLAGS) $(IMGUI_DIR)/imgui.cpp -o $@
$(OBJ_DIR)/imgui_demo.o:
$(CXX) -c $(CXXFLAGS) $(IMGUI_DIR)/imgui_demo.cpp -o $@
$(OBJ_DIR)/imgui_draw.o:
$(CXX) -c $(CXXFLAGS) $(IMGUI_DIR)/imgui_draw.cpp -o $@
$(OBJ_DIR)/imgui_impl_sdl_gl3.o:
$(CXX) -c $(CXXFLAGS) $(IMGUI_DIR)/examples/sdl_opengl3_example/imgui_impl_sdl_gl3.cpp -o $@
$(OBJ_DIR)/gl3w.o:
$(CC) -c $(GL3W_CFLAGS) $(IMGUI_DIR)/examples/libs/gl3w/GL/gl3w.c -o $@
.PHONY: clean
clean:
rm -f bin/hexgame $(OBJ_DIR)/*

40
src/Makefile

@ -1,40 +0,0 @@
CXX = g++
CXXFLAGS = -std=c++11 -g -ggdb -Wall -I/usr/include/SDL2 -I../ext/aixlog/include
# IMGUI
IMGUI_DIR = ../ext/imgui
# TODO: incorporate imgui into project files and not use gl3w
# can also remove -ldl from LDFLAGS then
CC = gcc
CFLAGS = -Wall -I$(IMGUI_DIR)/examples/libs/gl3w
OBJECTS = $(IMGUI_DIR)/examples/libs/gl3w/GL/gl3w.o
CXXFLAGS += -I$(IMGUI_DIR) -I$(IMGUI_DIR)/examples/sdl_opengl3_example -I$(IMGUI_DIR)/examples/libs/gl3w
OBJECTS += $(IMGUI_DIR)/examples/sdl_opengl3_example/imgui_impl_sdl_gl3.o
OBJECTS += $(IMGUI_DIR)/imgui.o $(IMGUI_DIR)/imgui_demo.o $(IMGUI_DIR)/imgui_draw.o
# libGLEW needs to be >= 2.0.0 to use opengl core context
# don't know a good way to require this in make without forcing a specific version
LDFLAGS = -lSDL2 -lGLEW -lGL
# SDL2_image
CXXFLAGS += $(shell pkg-config --cflags SDL2_image)
LDFLAGS += $(shell pkg-config --libs SDL2_image)
# TODO: only needed for gl3w, remove later
LDFLAGS += -ldl
LDFLAGS += -lassimp
all: $(OBJECTS)
$(CXX) $(CXXFLAGS) -o hexgame hexgame.cpp $(LDFLAGS) $(OBJECTS)
mkdir -p ../bin
mv hexgame ../bin
.PHONY: clean
clean:
rm ../bin/hexgame $(OBJECTS)

1
src/hexgame.cpp

@ -2,6 +2,7 @@
* TODO:
* - maybe start thinking about separating headers into different compilation units
* - add some sweet unit models
* - need to add indexed drawing for assimp models
* - map generation
* - pathfinding
*/

4
src/mesh.h

@ -47,6 +47,10 @@ getVertexCount()
return g_scene->mMeshes[0]->mNumVertices;
}
// TODO: probably don't really need to copy this here
// let assimp manage the storage, and just reference indexes after passing
// to opengl
// copy data from assimp for use in our renderer
Entity*
convertMesh(Entity* e)

Loading…
Cancel
Save