[ create a new paste ] login | about

Link: http://codepad.org/R9sAGQry    [ raw code | output | fork ]

C++, pasted on Dec 13:
#include <SFML/Graphics.hpp>

template <typename T>
struct Size
{
	Size(T _w, T _h) : w(_w), h(_h) {}
	
	T w;
	T h;
};

int main(int argc, char **argv)
{
	sf::RenderWindow aWindow(sf::VideoMode(800, 600), "SFML window");

	/* Calculate unit size... */

	const sf::Vector2f& aView(aWindow.GetView().GetSize());

	Size<float> unit( 	
		aView.x / 10.f,
		aView.y / 20.f	
	);

	while (aWindow.IsOpened()) 
	{
		aWindow.Clear();
		
		sf::Event event;
		
		while (aWindow.PollEvent(event)) 
		{
			if (event.Type == sf::Event::Closed)
				aWindow.Close();
				
			if (event.Type == sf::Event::Resized) /* Recalculate unit size */
			{
				unit.w = (float)(aView.x) / 10.f;
				unit.h = (float)(aView.y) / 20.f;
			}
		}
		
		/* Create outlined grid, 3 pixels thick */
		//sf::Shape grid_x[10];
		for (int i = 0; i <= 10; ++i)
		{
			float distance = unit.w * (i);
			aWindow.Draw(
				sf::Shape::Line( 
					distance, aView.y,
					distance, 0,
					1.f, sf::Color::White
					)
			);
		}
		
		for (int i = 0; i <= 20; ++i)
		{
			float distance = unit.h * (i);
			aWindow.Draw(
				sf::Shape::Line(
					aView.x, distance,
					0, distance,
					1.f, sf::Color::White
					)
			);
		}
		
		aWindow.Display();
	}

	return EXIT_SUCCESS;
}


Output:
1
2
3
4
Line 28: error: SFML/Graphics.hpp: No such file or directory
In function 'int main(int, char**)':
Line 14: error: 'sf' has not been declared
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: