Play Siv3D!

A free C++ library for games and interactive media

Introduction

Siv3D is a C++ library for games and interactive media. It supports many input devices such as Kinect, Leap Motion, webcams and microphones, and complex interactions can be coded in a few lines. The project was adopted by the Exploratory Software Project ('Mitoh' project in Japanese) directed by the IPA (Information-Technology Promotion Agency), Japan, in 2013. The latest version was released in August 2016. macOS support will be available in 2017.

Features

SMALL CODE, EASY TO LEARN
The interactive application which deals with sound and graphics can be developed by a few lines of code. For a interesting result can be obtained in a short time, it's also suitable for utilization in education.

IMAGE & AUDIO PROCESSING
Various audio and image processing such as changing the tempo and pitch of music, face detection, AR marker tracking, and posting an image on Twitter are available for easy programming.

SUPPORTS 10+ INPUT DEVICES
Interacting with mice, keyboards, Kinect v1/v2, Leap motion, webcams, microphones, pen tablets, gaming controllers, multi-touch screens, serial devices, and Arduino are available by default.


STATE OF THE ART C++
The library and the tutorial codes are written in C++11/14 style. You will learn how to create an application using state-of-the-art C++.

QUICK SETUP
The quick launch menu for Siv3D programming will appear on Visual Studio's new project dialog after installing the package. It takes only 30 seconds for building and running your very first Siv3D app.

SUPPORT AND COMMUNITY
Over 300 pieces of sample code are available on this reference, and frequently updated. You can also ask for questions in our support forum.


You can create a graphical and interactive application for a few lines of code.

# include <Siv3D.hpp>

void Main()
{
	const Font font(30);

	while (System::Update())
	{
		Circle(Mouse::Pos(), 100).draw();

		font(Mouse::Pos()).draw(50, 200, Palette::Orange);
	}
}

Ten types of image file format are supported, will help you to easily make an image viewer.

# include <Siv3D.hpp>

void Main()
{
	const Texture texture(L"Example/Windmill.png");

	while (System::Update())
	{
		texture.draw(100, 50);
	}
}

Making a paint application? It's a piece of cake! Changing color and thickness, image processing and saving will be implemented for additional several lines of code.

# include <Siv3D.hpp>

void Main()
{
	Image image(Window::Size(), Palette::White);

	DynamicTexture texture(image);

	while (System::Update())
	{
		if (Input::MouseL.pressed)
		{
			const Point pos = Input::MouseL.clicked ? Mouse::Pos() : Mouse::PreviousPos();

			Line(pos, Mouse::Pos()).overwrite(image, 8, Palette::Orange);

			texture.fill(image);
		}

		texture.draw();
	}
}

Various classes which represents shapes such as point, line segment, rectangle, circle, triangle, polygons and many others are available. A collision test between any of them can be coded in a single line.

# include <Siv3D.hpp>

void Main()
{
	const Rect rect(20, 20, 200, 100);

	const Circle circle(150, 300, 100);

	const Polygon star
	{
		{ 430, 100 }, { 470, 240 },
		{ 610, 240 }, { 505, 325 },
		{ 545, 460 }, { 430, 380 },
		{ 315, 460 }, { 355, 325 },
		{ 250, 240 }, { 390, 240 }
	};

	while (System::Update())
	{
		const Circle player(Mouse::Pos(), 30);

		rect.draw(player.intersects(rect) ? Palette::Red : Palette::Yellow);

		circle.draw(player.intersects(circle) ? Palette::Red : Palette::Yellow);

		star.draw(player.intersects(star) ? Palette::Red : Palette::Yellow);

		player.draw();
	}
}

Easily interact with cutting edge devices like Kinect v2 and Leap Motion. You can smoothly reflect player's action in your game.

# include <Siv3D.hpp>

void Main()
{
	if (!KinectV2::Start())
	{
		return;
	}

	DynamicTexture depthTexture;

	std::array<Optional<KinectV2Body>,6> bodies;

	while (System::Update())
	{
		if (KinectV2::HasNewDepthFrame())
		{
			KinectV2::GetDepthFrame(depthTexture);
		}

		if (KinectV2::HasNewBodyFrame())
		{
			KinectV2::GetBodyFrame(bodies);
		}

		depthTexture.draw();

		for (const auto& body : bodies)
		{
			if (!body)
			{
				continue;
			}

			for (const auto& joint : body->joints)
			{
				Circle(joint.depthSpacePos, 15).drawFrame(6.0, 0.0, Palette::Red);
			}
		}
	}
}

It only takes 5 minutes to make a music player. Sample code is available in Qiita.

No difficult techniques are required to represent 3D computer graphics. You can put at most 128 point lights in the scene. Fog and particles will produce fantastic effect on the screen.

# include <Siv3D.hpp>

void Main()
{
    const Texture texture(L"Example/Earth.jpg", TextureDesc::For3D);

    while (System::Update())
    {
        Graphics3D::FreeCamera();

        const double yaw = Time::GetMillisec() * -0.0001;

        Sphere(10, Quaternion::Yaw(yaw).roll(-23.4_deg)).draw(texture);
    }
}