Browse Source

first stab at pulling out renderer to new library

master
cinnaboot 6 years ago
parent
commit
453809c8dc
  1. 47
      Makefile
  2. 4
      src/gooey.cpp
  3. 2
      src/gooey.h
  4. 7
      src/hexgame.cpp
  5. 2
      src/hexgame.h
  6. 2
      src/hexgrid.h
  7. 34
      src/render/Makefile
  8. 0
      src/render/camera.cpp
  9. 2
      src/render/camera.h
  10. 0
      src/render/entity.cpp
  11. 2
      src/render/entity.h
  12. 0
      src/render/mesh.cpp
  13. 2
      src/render/mesh.h
  14. 0
      src/render/platform_wait_for_vblank.h
  15. 2
      src/render/render_group.cpp
  16. 2
      src/render/render_group.h
  17. 0
      src/render/renderer.cpp
  18. 4
      src/render/renderer.h
  19. 4
      src/scene_loader.cpp
  20. 4
      src/scene_loader.h

47
Makefile

@ -2,8 +2,8 @@
CXX = g++
CXXFLAGS = -std=c++11 -g -ggdb3 -Wall -I/usr/include/SDL2 -Iext/aixlog/include -Iext/stb_libs
SRC_DIR = src
OBJ_DIR = build
SRCDIR = src
OBJDIR = build
# TODO: incorporate imgui into project files and not use gl3w
# can also remove -ldl from LDFLAGS then
@ -14,7 +14,8 @@ 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
#LDFLAGS = -lSDL2 -lGLEW -lGL
LDFLAGS = -lSDL2 -lGL
# IMGUI
IMGUI_DIR = ext/imgui
@ -28,23 +29,29 @@ IMGUI_SOURCES = $(IMGUI_DIR)/imgui.cpp \
$(IMGUI_DIR)/examples/imgui_impl_opengl3.cpp \
$(IMGUI_DIR)/examplex/imgui_impl_sdl.cpp \
IMGUI_OBJECTS := $(patsubst %.cpp, $(OBJ_DIR)/%.o, $(notdir $(IMGUI_SOURCES)))
IMGUI_OBJECTS := $(patsubst %.cpp, $(OBJDIR)/%.o, $(notdir $(IMGUI_SOURCES)))
# assimp
LDFLAGS += -lassimp
SOURCES = $(wildcard $(SRC_DIR)/*.cpp)
OBJECTS = $(patsubst $(SRC_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(SOURCES))
SOURCES = $(wildcard $(SRCDIR)/*.cpp)
OBJECTS = $(patsubst $(SRCDIR)/%.cpp,$(OBJDIR)/%.o,$(SOURCES))
all: $(IMGUI_OBJECTS) $(OBJ_DIR)/gl3w.o $(OBJECTS)
$(CXX) -o $(OBJ_DIR)/hexgame $(LDFLAGS) $(GL3W_LDFLAGS) $(OBJ_DIR)/*.o
all: $(IMGUI_OBJECTS) $(OBJDIR)/gl3w.o $(OBJECTS) renderer
$(CXX) -o $(OBJDIR)/hexgame $(LDFLAGS) $(GL3W_LDFLAGS) $(OBJDIR)/*.o $(OBJDIR)/librender.a
mkdir -p bin
mv $(OBJ_DIR)/hexgame bin
mv $(OBJDIR)/hexgame bin
.PHONY: all
renderer:
$(MAKE) -C $(SRCDIR)/render
cp $(SRCDIR)/render/build/librender.a $(OBJDIR)
-include $(OBJ_DIR)/*.d
-include $(OBJDIR)/*.d
$(OBJECTS): $(OBJ_DIR)/%.o : $(SRC_DIR)/%.cpp
$(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.cpp
$(CXX) $(CXXFLAGS) -c -MMD $< -o $@
info:
@ -54,28 +61,28 @@ info:
@echo $(OBJECTS)
# NOTE: couldn't find a nicer way to put these object files into build directory :(
$(OBJ_DIR)/imgui.o:
$(OBJDIR)/imgui.o:
$(CXX) -c $(CXXFLAGS) $(IMGUI_DIR)/imgui.cpp -o $@
$(OBJ_DIR)/imgui_demo.o:
$(OBJDIR)/imgui_demo.o:
$(CXX) -c $(CXXFLAGS) $(IMGUI_DIR)/imgui_demo.cpp -o $@
$(OBJ_DIR)/imgui_draw.o:
$(OBJDIR)/imgui_draw.o:
$(CXX) -c $(CXXFLAGS) $(IMGUI_DIR)/imgui_draw.cpp -o $@
$(OBJ_DIR)/imgui_widgets.o:
$(OBJDIR)/imgui_widgets.o:
$(CXX) -c $(CXXFLAGS) $(IMGUI_DIR)/imgui_widgets.cpp -o $@
$(OBJ_DIR)/imgui_impl_opengl3.o:
$(OBJDIR)/imgui_impl_opengl3.o:
$(CXX) -c $(CXXFLAGS) $(IMGUI_DIR)/examples/imgui_impl_opengl3.cpp -o $@
$(OBJ_DIR)/imgui_impl_sdl.o:
$(OBJDIR)/imgui_impl_sdl.o:
$(CXX) -c $(CXXFLAGS) $(IMGUI_DIR)/examples/imgui_impl_sdl.cpp -o $@
$(OBJ_DIR)/gl3w.o:
$(OBJDIR)/gl3w.o:
$(CC) -c $(GL3W_CFLAGS) $(IMGUI_DIR)/examples/libs/gl3w/GL/gl3w.c -o $@
.PHONY: clean
clean:
rm -f bin/hexgame $(OBJ_DIR)/*
rm -f bin/hexgame $(OBJDIR)/*
$(MAKE) -C $(SRCDIR)/render clean

4
src/gooey.cpp

@ -11,8 +11,8 @@
#include "examples/imgui_impl_sdl.h"
#include "examples/imgui_impl_opengl3.h"
#include "camera.h"
#include "entity.h"
#include "render/camera.h"
#include "render/entity.h"
#include "hexgrid.h"
#include "gooey.h"
#include "util.h"

2
src/gooey.h

@ -2,7 +2,7 @@
#pragma once
#include "hexgame.h"
#include "renderer.h"
#include "render/renderer.h"
bool gooInit(SDL_Handles &handles, v2i vp_dims);

7
src/hexgame.cpp

@ -31,9 +31,10 @@
#include "gooey.h"
#include "hexgame.h"
#include "mesh.h"
#include "platform_wait_for_vblank.h"
#include "renderer.h"
#include "render/mesh.h"
#include "render/platform_wait_for_vblank.h"
#include "render/renderer.h"
#include "render/entity.h"
#include "scene_loader.h"
#include "util.h"

2
src/hexgame.h

@ -3,7 +3,7 @@
#include <glm/glm.hpp>
#include "entity.h"
#include "render/entity.h"
#include "hexgrid.h"
#include "util.h"

2
src/hexgrid.h

@ -5,7 +5,7 @@
#include <unordered_map>
#include "hexlib.h"
#include "render_group.h"
#include "render/render_group.h"
#include "util.h"

34
src/render/Makefile

@ -0,0 +1,34 @@
CXX = g++
CXXFLAGS = -std=c++11 -g -ggdb3 -Wall -I/usr/include/SDL2
OBJDIR = build
# TODO: remove aixlog
CXXFLAGS += -I../../ext/aixlog/include
# TODO: switch from gl3w to glew
IMGUI_DIR = ../../ext/imgui
CC = gcc
GL3W_CFLAGS = -g -Wall -I$(IMGUI_DIR)/examples/libs/gl3w
CXXFLAGS += -I$(IMGUI_DIR)/examples/libs/gl3w
GL3W_LDFLAGS += -ldl
RENDER_SOURCES = $(wildcard *.cpp)
RENDER_OBJECTS = $(patsubst %.cpp,$(OBJDIR)/%.o,$(RENDER_SOURCES))
all: $(RENDER_OBJECTS) $(OBJDIR)/gl3w.o
ar -crs $(OBJDIR)/librender.a $(RENDER_OBJECTS)
.PHONY: all
-include $(OBJDIR)/*.d
$(RENDER_OBJECTS): $(OBJDIR)/%.o : %.cpp
$(CXX) $(CXXFLAGS) -c -MMD $< -o $@
$(OBJDIR)/gl3w.o:
$(CC) -c $(GL3W_CFLAGS) $(IMGUI_DIR)/examples/libs/gl3w/GL/gl3w.c -o $@
.PHONY: clean
clean:
rm $(OBJDIR)/*

0
src/camera.cpp → src/render/camera.cpp

2
src/camera.h → src/render/camera.h

@ -2,7 +2,7 @@
#pragma once
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include "util.h"
#include "../util.h"
struct camera

0
src/entity.cpp → src/render/entity.cpp

2
src/entity.h → src/render/entity.h

@ -4,7 +4,7 @@
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include "hexgrid.h"
#include "../hexgrid.h"
#include "mesh.h"
#include "render_group.h"

0
src/mesh.cpp → src/render/mesh.cpp

2
src/mesh.h → src/render/mesh.h

@ -7,7 +7,7 @@
#include <glm/glm.hpp>
#include "util.h"
#include "../util.h"
struct meMeshInfo
{

0
src/platform_wait_for_vblank.h → src/render/platform_wait_for_vblank.h

2
src/render_group.cpp → src/render/render_group.cpp

@ -9,7 +9,7 @@
#include "aixlog.hpp"
#include "render_group.h"
#include "util.h"
#include "../util.h"
#define INFO_LOG_MAX_LENGTH 312

2
src/render_group.h → src/render/render_group.h

@ -4,7 +4,7 @@
#include <GL/gl3w.h>
#include <glm/glm.hpp>
#include "util.h"
#include "../util.h"
// TODO: can these structs be used as opaque pointers?

0
src/renderer.cpp → src/render/renderer.cpp

4
src/renderer.h → src/render/renderer.h

@ -13,9 +13,9 @@
#include "camera.h"
#include "entity.h"
#include "hexgrid.h"
#include "../hexgrid.h"
#include "render_group.h"
#include "util.h"
#include "../util.h"
struct SDL_Handles

4
src/scene_loader.cpp

@ -9,9 +9,9 @@
#include <rapidjson/writer.h>
#include "aixlog.hpp"
#include "entity.h"
#include "render/entity.h"
#include "hexlib.h"
#include "mesh.h"
#include "render/mesh.h"
#include "scene_loader.h"

4
src/scene_loader.h

@ -1,9 +1,9 @@
#pragma once
#include "camera.h"
#include "render/camera.h"
#include "hexgrid.h"
#include "render_group.h"
#include "render/render_group.h"
#include "util.h"

Loading…
Cancel
Save