From: Francois Fleuret Date: Sat, 27 Aug 2016 22:10:12 +0000 (+0200) Subject: Cosmetics + started to prepare use without X11. X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=commitdiff_plain;h=1772e738e79ad97347552ea29ee041440d9e60cb;p=universe.git Cosmetics + started to prepare use without X11. --- diff --git a/Makefile b/Makefile index 6fc991d..23d8458 100644 --- a/Makefile +++ b/Makefile @@ -13,17 +13,19 @@ # Contact for comments & bug reports # #============================================================================# -# CXX=g++-3.3 - 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 -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 diff --git a/move_square.cc b/move_square.cc index cf32bfb..c901422 100644 --- a/move_square.cc +++ b/move_square.cc @@ -29,8 +29,8 @@ public: 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); diff --git a/polygon.cc b/polygon.cc index 1c109c3..1d2b3dd 100644 --- a/polygon.cc +++ b/polygon.cc @@ -56,6 +56,7 @@ void Polygon::print_xfig(XFigTracer *tracer) { _nb_vertices, _x, _y); } +#ifdef X11_SUPPORT 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]); } } +#endif #ifdef CAIRO_SUPPORT void Polygon::draw(cairo_t* context_resource) { diff --git a/polygon.h b/polygon.h index 46eda3e..48e6d3b 100644 --- a/polygon.h +++ b/polygon.h @@ -6,9 +6,12 @@ #define POLYGON_H #include "misc.h" -#include "simple_window.h" #include "xfig_tracer.h" +#ifdef X11_SUPPORT +#include "simple_window.h" +#endif + #ifdef CAIRO_SUPPORT #include #endif @@ -73,8 +76,10 @@ public: void color_xfig(XFigTracer *tracer); void print_xfig(XFigTracer *tracer); +#ifdef X11_SUPPORT void draw(SimpleWindow *window); void draw_contours(SimpleWindow *window); +#endif #ifdef CAIRO_SUPPORT void draw(cairo_t* context_resource); diff --git a/universe.cc b/universe.cc index 9522dfd..b0c28dd 100644 --- a/universe.cc +++ b/universe.cc @@ -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]) { @@ -142,6 +143,7 @@ void Universe::draw(SimpleWindow *window) { } } } +#endif #ifdef CAIRO_SUPPORT void Universe::draw(cairo_t *context_resource) { diff --git a/universe.h b/universe.h index 77980b8..f87f112 100644 --- a/universe.h +++ b/universe.h @@ -8,16 +8,19 @@ #include #include +#include "misc.h" +#include "polygon.h" + +#ifdef X11_SUPPORT +#include "simple_window.h" +#endif + #ifdef CAIRO_SUPPORT #include #endif using namespace std; -#include "misc.h" -#include "simple_window.h" -#include "polygon.h" - 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); + +#ifdef X11_SUPPORT void draw(SimpleWindow *window); +#endif #ifdef CAIRO_SUPPORT void draw(cairo_t *context_resource);