2 #include <unistd.h> // Because we can.
4 #include "controlpanel.h"
8 int main(int argc, char ** argv)
10 #ifndef __STDC_IEC_559__
11 Warn("__STDC_IEC_559__ not defined. IEEE 754 floating point not fully supported.\n");
15 Debug("Compiled with REAL = %d => \"%s\" sizeof(Real) == %d bytes", REAL, g_real_name[REAL], sizeof(Real));
20 enum {OUTPUT_TO_BMP, LOOP} mode = LOOP;
24 const char * input_bmp = NULL;
25 const char * output_bmp = NULL;
26 const char * input_filename = NULL;
27 float b[4] = {0,0,1,1};
32 if (argv[i][0] != '-')
34 input_filename = argv[i];
42 Fatal("No input argument following -o switch");
45 Fatal("No output argument following -o switch");
51 Debug("Reading paint colour");
52 for (int j = 1; j <= 4; ++j)
55 Fatal("No %d colour component following -c switch", j);
57 float * comp = (j == 1) ? (&c.r) : ((j == 2) ? (&c.g) : ((j == 3) ? (&c.b) : &(c.a)));
58 *comp = strtof(argv[i+j], &e);
60 Fatal("Colour component %d not a valid float", j);
67 Debug("Reading view bounds");
68 for (int j = 1; j <= 4; ++j)
71 Fatal("No %d bounds component following -b switch", j);
73 b[j-1] = strtof(argv[i+j], &e);
75 Fatal("Bounds component %d not a valid float", j);
83 if (input_filename != NULL)
85 doc.LoadSVG(input_filename, Rect(0,0,Real(1)/Real(800),Real(1)/Real(600)));
89 //doc.AddBezier(Bezier(0,0, 1,0.5, 0.5,1, 1,1));
90 doc.AddText("The quick brown\nfox jumps over\nthe lazy dog",0.1,0,0.5);
91 //doc.AddBezier(Bezier(0,0,0,0.1,0,0.1,0,0.1));
94 Rect bounds(b[0],b[1],b[2],b[3]);
97 View view(doc,scr, bounds);
99 #ifndef CONTROLPANEL_DISABLED
100 ControlPanel::RunArgs args = {argc, argv, view, doc, scr};
101 SDL_Thread * cp_thread = SDL_CreateThread(ControlPanel::Run, "ControlPanel", &args);
102 if (cp_thread == NULL)
104 Error("Couldn't create ControlPanel thread: %s", SDL_GetError());
106 #endif //CONTROLPANEL_DISABLED
109 MainLoop(doc, scr, view);
110 else if (mode == OUTPUT_TO_BMP) //TODO: Remove this shit
111 OverlayBMP(doc, input_bmp, output_bmp, bounds, c);
113 #ifndef CONTROLPANEL_DISABLED
115 if (cp_thread != NULL)
118 qApp->quit(); // will close the control panel
119 // (seems to not explode if the qApp has already been quit)
120 SDL_WaitThread(cp_thread, &cp_return);
121 Debug("ControlPanel thread returned %d", cp_return);
123 #endif //CONTROLPANEL_DISABLED