Esempio n. 1
0
SecondaryWindow::SecondaryWindow(const WindowParams& wp, bool bIsFullscreen,
        GLConfig glConfig)
    : Window(wp, bIsFullscreen)
{
#ifdef linux
    GLContext* pMainContext = GLContext::getCurrent();
    GLContext* pGLContext;
    IntRect windowDimensions(wp.m_Pos, wp.m_Pos+wp.m_Size);
    string sDisplay = ":0." + toString(wp.m_DisplayServer);
    pGLContext = new SecondaryGLXContext(glConfig, sDisplay, windowDimensions,
            wp.m_bHasWindowFrame);
    setGLContext(pGLContext);
    
    pMainContext->activate();
#endif
}
Esempio n. 2
0
	void initialize() override
	{
		const auto size = windowDimensions();
		linear_scale<float, float> window_scale(0, 1000, 0, size.x);
		linear_scale<float, float> lower_bottom(0, size.x, 5 * size.y / 6, 5 * size.y / 6);
		linear_scale<float, float> lower_top(0, size.x, 2 * size.y / 3, size.y / 6);
		linear_scale<float, float> upper_bottom(0, size.x, size.y / 3, 5 * size.y / 6);
		linear_scale<float, float> upper_top(0, size.x, size.y / 6, size.y / 6);
		linear_scale<float, float> x_scale(0, std::sqrt(size.x), 0, size.x);
		linear_color_scale<float> color_scale(0, size.x, sf::Color(128, 128, 128), sf::Color::Black);
		linear_scale<float, float> size_scale(0, size.x, 1, 6);

		const unsigned num_rects(15);
		sf::RectangleShape rect(sf::Vector2f(window_scale(100), window_scale(20)));
		rect.setOrigin(window_scale(50), window_scale(10));
		rect.setFillColor(sf::Color::Black);
		rect.setOutlineColor(sf::Color::White);
		rect.setOutlineThickness(window_scale(-1));

		sf::Vector2f top_left(0, 0);
		sf::Vector2f bottom_right(std::sqrt(size.x), size.y);
		maxProgress(num_rects);
		for(unsigned i = 0; i < num_rects; ++i)
		{
			float x = x_scale(randuniform(0, std::sqrt(size.x)));
			float scale = size_scale(x);
			rect.setScale(scale, scale);
			rect.setOutlineThickness(window_scale(-1)/scale);
			float y = linear_scale<float, float>(0, size.y, upper_top(x), upper_bottom(x))(randuniform(0, size.y));
			rect.setFillColor(color_scale(x));
			rect.setPosition(x, y);
			rects.push_back(rect);
			addProgress(0.5);
			y = linear_scale<float, float>(0, size.y, lower_top(x), lower_bottom(x))(randuniform(0, size.y));
			rect.setFillColor(sf::Color::Black);
			rect.setPosition(x, y);
			rects.push_back(rect);
			addProgress(0.5);
		}
		std::sort(rects.begin(), rects.end(), [](const sf::RectangleShape& lhs, const sf::RectangleShape& rhs)
		{
			return lhs.getPosition().x > rhs.getPosition().x;
		});

	}
Esempio n. 3
0
	void initialize() override
	{
		const float max_depth = 6000;
		const float min_depth = 0;
		const unsigned num_planes = 75;
		const unsigned rects_per_plane = 10;
		const float interval = ((max_depth - min_depth) / num_planes);
		const auto center = windowHalfDimensions();
		const auto dimensions = windowDimensions();

		auto plane = VanishPlane::backPlane(sf::Vector2f(center.x, center.y*1.2), 0);
		planes.reserve(num_planes);

		const sf::Vector2f rect_size(50, 250);
		sf::RectangleShape shape_base(rect_size);
		shape_base.setOrigin(rect_size.x / 2, rect_size.y);
		shape_base.setFillColor(sf::Color::Black);
		shape_base.setOutlineColor(sf::Color::White);
		const unsigned num_points = shape_base.getPointCount();

		const sf::Vector2f ground_size(100000, 100);
		sf::RectangleShape ground(ground_size);
		ground.setOrigin(ground_size.x / 2, 0);
		ground.setPosition(center.x, dimensions.y);
		ground.setFillColor(sf::Color::White);
		ground.setOutlineColor(sf::Color::Transparent);
		
		maxProgress(num_planes * (rects_per_plane+1));

		for(unsigned n_plane = num_planes; n_plane > 0; --n_plane)
		{
			plane.intersect = (n_plane * interval) + min_depth;

			planes.emplace_back();
			auto& rects = planes.back().rects;
			rects.reserve(rects_per_plane);

			if(n_plane == int(num_planes*.6))
			{
				const sf::Vector2f mighty_size(2000, 20000);
				sf::RectangleShape mighty(mighty_size);
				mighty.setOrigin(mighty_size.x / 2, mighty_size.y);
				mighty.setPosition(center.x * 10, dimensions.y);
				mighty.setFillColor(sf::Color::Black);
				mighty.setOutlineColor(sf::Color::White);
				rects.push_back(convertRectToConvex(mighty, plane));
			}


			for(unsigned rect = 0; rect < rects_per_plane; ++rect)
			{
				shape_base.setPosition(
					randcentered(center.x, center.x * sqrt(n_plane) * 5),
					dimensions.y + randuniform(0, 50));
				shape_base.setRotation(randuniform(-30, 30));
				rects.push_back(convertRectToConvex(shape_base, plane));
				addProgress(1);
			}
			rects.push_back(convertRectToConvex(ground, plane));
			addProgress(1);
		}
	}