diff --git a/Makefile b/Makefile index 9d3a0b1..9c86b26 100644 --- a/Makefile +++ b/Makefile @@ -1,39 +1,8 @@ -WINCHECK := $(shell which msys-1.0.dll >/dev/null 2>&1; if [ $$? -eq 0 ]; then echo MSYS; fi) -ifeq ($(strip $(WINCHECK)),) -WINDOWS := 0 -else -WINDOWS := 1 -endif +export SCONSFLAGS := -Q -ifeq ($(WINDOWS),1) -GLLIBS := -lopengl32 -lglu32 -WINDOWSLIBS := -lmingw32 -else -GLLIBS := -lGL -lGLU -endif - -export CXXFLAGS := -O2 $(shell sdl-config --cflags) -I$(CURDIR) -LDFLAGS := $(GLLIBS) $(WINDOWSLIBS) $(shell sdl-config --libs) -lSDL_image -TARGET := wfobj-view - -.PHONY: all clean TextureCache wfobj - -all: $(TARGET) - -$(TARGET): $(TARGET).o TextureCache wfobj - $(CXX) -o $(TARGET) $< TextureCache/TextureCache.o wfobj/WFObj.o $(LDFLAGS) - -%.o: %.cc - $(CXX) -c -o $@ $< $(CXXFLAGS) - -TextureCache: - make -C TextureCache - -wfobj: - make -C wfobj +all: + @scons clean: - make -C TextureCache clean - make -C wfobj clean - -rm -f *.o *~ $(TARGET) + @scons -c diff --git a/SConstruct b/SConstruct new file mode 100644 index 0000000..93b6cc9 --- /dev/null +++ b/SConstruct @@ -0,0 +1,6 @@ +# vim:filetype=python + +env = Environment(LIBS = ['GL', 'GLU']) +env.ParseConfig('sdl-config --cflags --libs') + +env.Program('wfobj-view', [Glob('*.cc'), Glob('wfobj/WFObj.cc')]) diff --git a/wfobj-view.cc b/wfobj-view.cc index 854eddd..cc381ba 100644 --- a/wfobj-view.cc +++ b/wfobj-view.cc @@ -5,7 +5,6 @@ #include #include #include "wfobj/WFObj.h" -#include "TextureCache/TextureCache.h" using namespace std; /* Some definitions */ @@ -13,18 +12,6 @@ using namespace std; #define HEIGHT 800 #define TITLE "Josh's Wavefront Object Viewer" -TextureCache textureCache; - -class LoadTexture : public TextureLoader -{ - public: - GLuint load(const FileLoader::Path & path, - FileLoader & fl, bool mipmaps, int mode, int quality) - { - return textureCache.load(path.fullPath); - } -}; - class Viewer { public: @@ -36,6 +23,7 @@ private: void display(); void setProjection(); + WFObj m_obj; GLuint m_list; float m_rotationMatrix[16]; int m_startx, m_starty; @@ -80,10 +68,7 @@ Viewer::Viewer(const char * filename) { m_dist = 5.0; m_dragging = false; - LoadTexture lt; - WFObj m_obj(lt); - m_obj.load(FileLoader::Path(filename, "")); - m_list = m_obj.render(); + m_obj.load(filename); /* Print out the object's size */ const float * aabb = m_obj.getAABB(); @@ -127,8 +112,7 @@ void Viewer::display() glLoadIdentity(); gluLookAt(0, -m_dist, 0, 0, 0, 0, 0, 0, 1); glMultMatrixf(m_rotationMatrix); - if (m_list) - glCallList(m_list); + m_obj.draw(); SDL_GL_SwapBuffers(); } @@ -196,5 +180,4 @@ void Viewer::run() } } } - }