Cosmetics + started to prepare use without X11.
authorFrancois Fleuret <francois@fleuret.org>
Sat, 27 Aug 2016 22:10:12 +0000 (00:10 +0200)
committerFrancois Fleuret <francois@fleuret.org>
Sat, 27 Aug 2016 22:10:12 +0000 (00:10 +0200)
Makefile
move_square.cc
polygon.cc
polygon.h
universe.cc
universe.h

index 6fc991d..23d8458 100644 (file)
--- a/Makefile
+++ b/Makefile
 # Contact <francois.fleuret@epfl.ch> for comments & bug reports                     #
 #============================================================================#
 
 # Contact <francois.fleuret@epfl.ch> for comments & bug reports                     #
 #============================================================================#
 
-# CXX=g++-3.3
-
 ifeq ($(DEBUG),yes)
  CXXFLAGS = -fPIC -Wall -g -DDEBUG
 else
  # Optimized compilation
 ifeq ($(DEBUG),yes)
  CXXFLAGS = -fPIC -Wall -g -DDEBUG
 else
  # Optimized compilation
- CXXFLAGS = -Wall -g -O3 -pg --coverage
+ # CXXFLAGS = -Wall -g -O3 -pg --coverage
  CXXFLAGS = -fPIC -Wall -g -O3
 endif
 
  CXXFLAGS = -fPIC -Wall -g -O3
 endif
 
-LDFLAGS = -L/usr/X11R6/lib/ -lz -ldl
+LDFLAGS = -lz -ldl
+
+# Do we use X11?
+CXXFLAGS += -DX11_SUPPORT
+LDFLAGS += -L/usr/X11R6/lib/
 
 # Do we use cairo?
 CXXFLAGS += -I/usr/include/cairo -DCAIRO_SUPPORT
 
 # Do we use cairo?
 CXXFLAGS += -I/usr/include/cairo -DCAIRO_SUPPORT
index cf32bfb..c901422 100644 (file)
@@ -29,8 +29,8 @@ public:
     else if(degree == 1) _square_size = 150;
     else if(degree == 2) _square_size = 100;
     else _square_size = 50;
     else if(degree == 1) _square_size = 150;
     else if(degree == 2) _square_size = 100;
     else _square_size = 50;
-    scalar_t x[] = { -_square_size/2.0, _square_size/2.0, _square_size/2.0, -_square_size/2.0 };
-    scalar_t y[] = { -_square_size/2.0, -_square_size/2.0, _square_size/2.0, _square_size/2.0 };
+    scalar_t x[] = { -_square_size / 2.0, _square_size / 2.0, _square_size / 2.0, -_square_size / 2.0 };
+    scalar_t y[] = { -_square_size / 2.0, -_square_size / 2.0, _square_size / 2.0, _square_size / 2.0 };
     _target = new Polygon(0.5, 1.0, 1.0, 0.0, x, y, 4);
     _target->set_position(_square_size/2, _square_size/2 + (world_height - _square_size) * drand48(), 0);
     _target->set_speed(0, 0, 0);
     _target = new Polygon(0.5, 1.0, 1.0, 0.0, x, y, 4);
     _target->set_position(_square_size/2, _square_size/2 + (world_height - _square_size) * drand48(), 0);
     _target->set_speed(0, 0, 0);
index 1c109c3..1d2b3dd 100644 (file)
@@ -56,6 +56,7 @@ void Polygon::print_xfig(XFigTracer *tracer) {
                        _nb_vertices, _x, _y);
 }
 
                        _nb_vertices, _x, _y);
 }
 
+#ifdef X11_SUPPORT
 void Polygon::draw(SimpleWindow *window) {
   window->color(_red, _green, _blue);
   int x[_nb_vertices], y[_nb_vertices];
 void Polygon::draw(SimpleWindow *window) {
   window->color(_red, _green, _blue);
   int x[_nb_vertices], y[_nb_vertices];
@@ -78,6 +79,7 @@ void Polygon::draw_contours(SimpleWindow *window) {
     window->draw_line(x[n], y[n], x[(n+1)%_nb_vertices], y[(n+1)%_nb_vertices]);
   }
 }
     window->draw_line(x[n], y[n], x[(n+1)%_nb_vertices], y[(n+1)%_nb_vertices]);
   }
 }
+#endif
 
 #ifdef CAIRO_SUPPORT
 void Polygon::draw(cairo_t* context_resource) {
 
 #ifdef CAIRO_SUPPORT
 void Polygon::draw(cairo_t* context_resource) {
index 46eda3e..48e6d3b 100644 (file)
--- a/polygon.h
+++ b/polygon.h
@@ -6,9 +6,12 @@
 #define POLYGON_H
 
 #include "misc.h"
 #define POLYGON_H
 
 #include "misc.h"
-#include "simple_window.h"
 #include "xfig_tracer.h"
 
 #include "xfig_tracer.h"
 
+#ifdef X11_SUPPORT
+#include "simple_window.h"
+#endif
+
 #ifdef CAIRO_SUPPORT
 #include <cairo.h>
 #endif
 #ifdef CAIRO_SUPPORT
 #include <cairo.h>
 #endif
@@ -73,8 +76,10 @@ public:
   void color_xfig(XFigTracer *tracer);
   void print_xfig(XFigTracer *tracer);
 
   void color_xfig(XFigTracer *tracer);
   void print_xfig(XFigTracer *tracer);
 
+#ifdef X11_SUPPORT
   void draw(SimpleWindow *window);
   void draw_contours(SimpleWindow *window);
   void draw(SimpleWindow *window);
   void draw_contours(SimpleWindow *window);
+#endif
 
 #ifdef CAIRO_SUPPORT
   void draw(cairo_t* context_resource);
 
 #ifdef CAIRO_SUPPORT
   void draw(cairo_t* context_resource);
index 9522dfd..b0c28dd 100644 (file)
@@ -129,6 +129,7 @@ void Universe::print_xfig(XFigTracer *tracer) {
   }
 }
 
   }
 }
 
+#ifdef X11_SUPPORT
 void Universe::draw(SimpleWindow *window) {
   for(int n = 0; n < _nb_polygons; n++) {
     if(_polygons[n]) {
 void Universe::draw(SimpleWindow *window) {
   for(int n = 0; n < _nb_polygons; n++) {
     if(_polygons[n]) {
@@ -142,6 +143,7 @@ void Universe::draw(SimpleWindow *window) {
     }
   }
 }
     }
   }
 }
+#endif
 
 #ifdef CAIRO_SUPPORT
 void Universe::draw(cairo_t *context_resource) {
 
 #ifdef CAIRO_SUPPORT
 void Universe::draw(cairo_t *context_resource) {
index 77980b8..f87f112 100644 (file)
@@ -8,16 +8,19 @@
 #include <iostream>
 #include <cmath>
 
 #include <iostream>
 #include <cmath>
 
+#include "misc.h"
+#include "polygon.h"
+
+#ifdef X11_SUPPORT
+#include "simple_window.h"
+#endif
+
 #ifdef CAIRO_SUPPORT
 #include <cairo.h>
 #endif
 
 using namespace std;
 
 #ifdef CAIRO_SUPPORT
 #include <cairo.h>
 #endif
 
 using namespace std;
 
-#include "misc.h"
-#include "simple_window.h"
-#include "polygon.h"
-
 class Universe {
   scalar_t _xmax, _ymax;
 public:
 class Universe {
   scalar_t _xmax, _ymax;
 public:
@@ -45,7 +48,10 @@ public:
   Polygon *pick_polygon(scalar_t x, scalar_t y);
 
   void print_xfig(XFigTracer *tracer);
   Polygon *pick_polygon(scalar_t x, scalar_t y);
 
   void print_xfig(XFigTracer *tracer);
+
+#ifdef X11_SUPPORT
   void draw(SimpleWindow *window);
   void draw(SimpleWindow *window);
+#endif
 
 #ifdef CAIRO_SUPPORT
   void draw(cairo_t *context_resource);
 
 #ifdef CAIRO_SUPPORT
   void draw(cairo_t *context_resource);