Blame c++/contourgl/contourgl.cpp

f2b8c4
/*
f2b8c4
    ......... 2015 Ivan Mahonin
f2b8c4
f2b8c4
    This program is free software: you can redistribute it and/or modify
f2b8c4
    it under the terms of the GNU General Public License as published by
f2b8c4
    the Free Software Foundation, either version 3 of the License, or
f2b8c4
    (at your option) any later version.
f2b8c4
f2b8c4
    This program is distributed in the hope that it will be useful,
f2b8c4
    but WITHOUT ANY WARRANTY; without even the implied warranty of
f2b8c4
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
f2b8c4
    GNU General Public License for more details.
f2b8c4
f2b8c4
    You should have received a copy of the GNU General Public License
f2b8c4
    along with this program.  If not, see <http: licenses="" www.gnu.org="">.</http:>
f2b8c4
*/
f2b8c4
f2b8c4
#include <iostream></iostream>
f2b8c4
93cbac
#include "test.h"
f29469
#include "measure.h"
f2b8c4
f2b8c4
f2b8c4
using namespace std;
f2b8c4
f2b8c4
f2b8c4
int main() {
f29469
	int width = 512;
f29469
	int height = 512;
7704aa
f29469
	Rect bounds_file;
f29469
	bounds_file.p0 = Vector(0.0, 450.0);
f29469
	bounds_file.p1 = Vector(500.0, -50.0);
f29469
f29469
	Rect bounds_frame;
f29469
	bounds_frame.p0 = Vector();
f29469
	bounds_frame.p1 = Vector(width, height);
f29469
f29469
	Rect bounds_gl;
f29469
	bounds_gl.p0 = Vector(-1.0, -1.0);
f29469
	bounds_gl.p1 = Vector( 1.0,  1.0);
f29469
f29469
	{
f29469
		// lines
f29469
f29469
		Test::Data data, gldata, datalow;
f29469
		Test::load(data, "lines.txt");
f29469
		Test::transform(data, bounds_file, bounds_frame);
f29469
f29469
		gldata = data;
f29469
		Test::transform(gldata, bounds_frame, bounds_gl);
f29469
		{ Environment e(width, height, false, false, 8);
f29469
		  Measure t("test_lines_gl_stencil.tga", true);
f29469
		  Test::test_gl_stencil(e, gldata); }
f29469
		{ Environment e(width, height, false, true, 8);
f29469
		  Measure t("test_lines_gl_stencil_aa.tga", true);
f29469
		  Test::test_gl_stencil(e, gldata); }
f29469
		{
f29469
			Environment e(width, height, false, false, 8);
f29469
			{ Surface surface(width, height);
f29469
			  Measure t("test_lines_sw.tga", surface, true);
f29469
			  Test::test_sw(e, data, surface); }
f29469
			{ Surface surface(width, height);
f29469
			  Measure t("test_lines_cl.tga", surface, true);
f29469
			  Test::test_cl(e, data, surface); }
f29469
		}
f29469
		{ Measure t("test_lines_downgrade", true); Test::downgrade(data, datalow); }
f29469
f29469
		gldata = datalow;
f29469
		Test::transform(gldata, bounds_frame, bounds_gl);
f29469
		{ Environment e(width, height, false, false, 8);
f29469
		  Measure t("test_lineslow_gl_stencil.tga", true);
f29469
		  Test::test_gl_stencil(e, gldata); }
f29469
		{ Environment e(width, height, false, true, 8);
f29469
		  Measure t("test_lineslow_gl_stencil_aa.tga", true);
f29469
		  Test::test_gl_stencil(e, gldata); }
f29469
		{
f29469
			Environment e(width, height, false, false, 8);
f29469
			{ Surface surface(width, height);
f29469
			  Measure t("test_lineslow_sw.tga", surface, true);
f29469
			  Test::test_sw(e, datalow, surface); }
f29469
			{ Surface surface(width, height);
f29469
			  Measure t("test_lineslow_cl.tga", surface, true);
f29469
			  Test::test_cl(e, datalow, surface); }
f29469
		}
f29469
	}
f29469
f29469
	if (false ){
f29469
		// splines
f29469
f29469
		Test::Data data, ldata, gldata;
f29469
		Test::load(data, "splines.txt");
f29469
		Test::transform(data, bounds_file, bounds_frame);
f29469
		Environment e(width, height, false, false, 8);
f29469
f29469
		{ Environment e(width, height, false, true, 8);
f29469
		  Measure t("test_splines_gl_stencil.tga", true);
f29469
		  { Measure t("split"); Test::split(data, gldata); }
f29469
		  Test::transform(gldata, bounds_frame, bounds_gl);
f29469
		  Test::test_gl_stencil(e, gldata); }
f29469
		{ Environment e(width, height, false, true, 8);
f29469
		  Measure t("test_splines_gl_stencil_aa.tga", true);
f29469
		  { Measure t("split"); Test::split(data, gldata); }
f29469
		  Test::transform(gldata, bounds_frame, bounds_gl);
f29469
		  Test::test_gl_stencil(e, gldata); }
f29469
		e.use();
f29469
		{ Surface surface(width, height);
f29469
		  Measure t("test_splines_sw.tga", surface, true);
f29469
		  Test::test_sw(e, data, surface); }
f29469
		{ Surface surface(width, height);
f29469
		  Measure t("test_splines_cl.tga", surface, true);
f29469
		  { Measure t("split"); Test::split(data, ldata); }
f29469
		  Test::test_cl(e, ldata, surface); }
f29469
	}
f2b8c4
f2b8c4
	cout << "done" << endl;
f2b8c4
	return 0;
f2b8c4
}