goat3d

changeset 92:ae6c5941faac

[goatview] makefile rules to create app bundle and dmg archive [goatview] creating multisampling context
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 18 May 2014 01:19:10 +0300
parents f92da4fa9a6d
children 07c0ec4a410d
files goatview/Makefile goatview/src/goatview.cc
diffstat 2 files changed, 48 insertions(+), 2 deletions(-) [+]
line diff
     1.1 --- a/goatview/Makefile	Sat May 17 15:42:10 2014 +0300
     1.2 +++ b/goatview/Makefile	Sun May 18 01:19:10 2014 +0300
     1.3 @@ -14,7 +14,7 @@
     1.4  
     1.5  CFLAGS = $(warn) -g $(pic) -I$(goat_root)/src $(qtinc)
     1.6  CXXFLAGS = -std=c++11 $(CFLAGS)
     1.7 -LDFLAGS = $(libgoat) $(libgl) $(qtlib) -lvmath
     1.8 +LDFLAGS = $(libgoat) $(libgl) $(qtlib) -lvmath -lanim
     1.9  MOC = moc
    1.10  
    1.11  qtinc = `pkg-config --cflags Qt5Gui Qt5Core Qt5OpenGL`
    1.12 @@ -24,6 +24,8 @@
    1.13  	libgl = -framework OpenGL -framework GLUT -lGLEW
    1.14  	libgoat = $(goat_root)/libgoat3d.dylib
    1.15  	warn += -Wno-deprecated-declarations
    1.16 +	bundle = $(bin).app
    1.17 +	dmg = $(bin).dmg
    1.18  else
    1.19  	pic = -fPIC
    1.20  	libgl = -lGL -lGLU -lglut -lGLEW
    1.21 @@ -35,6 +37,7 @@
    1.22  endif
    1.23  ifneq ($(shell $(CC) --version | grep LLVM),)
    1.24  	CXXFLAGS += -stdlib=libc++
    1.25 +	warn += '-Wno-\#warnings'
    1.26  endif
    1.27  
    1.28  $(bin): $(obj) $(libgoat)
    1.29 @@ -55,6 +58,8 @@
    1.30  .PHONY: clean
    1.31  clean:
    1.32  	rm -f $(obj) $(bin)
    1.33 +	[ -n "$(bundle)" ] && rm -rf $(bundle) || true
    1.34 +	[ -n "$(dmg)" ] && rm -rf $(dmg) || true
    1.35  
    1.36  .PHONY: cleandep
    1.37  cleandep:
    1.38 @@ -67,3 +72,36 @@
    1.39  .PHONY: uninstall
    1.40  uninstall:
    1.41  	rm -f $(DESTDIR)$(PREFIX)/bin/$(bin)
    1.42 +
    1.43 +.PHONY: echo
    1.44 +echo:
    1.45 +	@echo $(var)=\"$($(var))\"
    1.46 +
    1.47 +.PHONY: bundle
    1.48 +bundle: $(bundle)
    1.49 +
    1.50 +.PHONY: dmg
    1.51 +dmg: $(dmg)
    1.52 +
    1.53 +$(bundle): $(bin) $(libgoat)
    1.54 +	rm -rf $(bundle)
    1.55 +	mkdir -p $(bundle)/Contents/MacOS
    1.56 +	mkdir -p $(bundle)/Contents/Frameworks
    1.57 +	cp $(bin) $(bundle)/Contents/MacOS/$(bin)
    1.58 +	macdeployqt $(bundle)
    1.59 +	cp $(libgoat) $(bundle)/Contents/Frameworks
    1.60 +	cp /usr/local/lib/libvmath.dylib $(bundle)/Contents/Frameworks
    1.61 +	cp /usr/local/lib/libanim.dylib $(bundle)/Contents/Frameworks
    1.62 +
    1.63 +$(dmg): $(bundle)
    1.64 +	rm -f $@
    1.65 +	hdiutil create -format UDBZ -quiet -srcfolder $< $@
    1.66 +
    1.67 +.PHONY: run
    1.68 +ifeq ($(shell uname -s), Darwin)
    1.69 +run: $(bundle)
    1.70 +	./$(bundle)/Contents/MacOS/$(bin)
    1.71 +else
    1.72 +run: $(bin)
    1.73 +	./$(bin)
    1.74 +endif
     2.1 --- a/goatview/src/goatview.cc	Sat May 17 15:42:10 2014 +0300
     2.2 +++ b/goatview/src/goatview.cc	Sun May 18 01:19:10 2014 +0300
     2.3 @@ -21,6 +21,7 @@
     2.4  static float fov = 60.0;
     2.5  static bool use_nodes = true;
     2.6  static bool use_lighting = true;
     2.7 +static bool use_textures = true;
     2.8  
     2.9  void post_redisplay()
    2.10  {
    2.11 @@ -35,11 +36,16 @@
    2.12  	glview = 0;
    2.13  	scene_model = 0;
    2.14  
    2.15 +	QGLFormat glfmt = QGLFormat::defaultFormat();
    2.16 +	glfmt.setSampleBuffers(true);
    2.17 +	QGLFormat::setDefaultFormat(glfmt);
    2.18 +
    2.19  	QSettings settings;
    2.20  	resize(settings.value("main/size", QSize(1024, 768)).toSize());
    2.21  	move(settings.value("main/pos", QPoint(100, 100)).toPoint());
    2.22  	use_nodes = settings.value("use_nodes", true).toBool();
    2.23  	use_lighting = settings.value("use_lighting", true).toBool();
    2.24 +	use_textures = settings.value("use_textures", true).toBool();
    2.25  
    2.26  	make_center();	// must be first
    2.27  	make_menu();
    2.28 @@ -237,7 +243,7 @@
    2.29  
    2.30  // ---- OpenGL viewport ----
    2.31  GoatViewport::GoatViewport(QWidget *main_win)
    2.32 -	: QGLWidget(QGLFormat(QGL::DepthBuffer))
    2.33 +	: QGLWidget(QGLFormat(QGL::DepthBuffer | QGL::SampleBuffers))
    2.34  {
    2.35  	this->main_win = main_win;
    2.36  	initialized = false;
    2.37 @@ -281,6 +287,8 @@
    2.38  
    2.39  	float ldir[] = {-1, 1, 2, 0};
    2.40  	glLightfv(GL_LIGHT0, GL_POSITION, ldir);
    2.41 +
    2.42 +	glEnable(GL_MULTISAMPLE);
    2.43  }
    2.44  
    2.45  void GoatViewport::resizeGL(int xsz, int ysz)