Пример #1
0
	void Core_Imp::DrawSceneToWindowWithTransition(CoreScene* nextScene, CoreScene* previousScene, CoreTransition* transition)
	{
		auto t = (CoreTransition_Imp*) transition;

		m_graphics->SetRenderTarget(nullptr, nullptr);

		t->DrawCache(layerRenderer, nextScene, previousScene);
		t->ClearCache();
	}
Пример #2
0
void Graphics_LayerRenderer(bool isOpenGLMode)
{
	StartGraphicsTest();
	SetGLEnable(isOpenGLMode);

	asd::Log* log = asd::Log_Imp::Create(u"graphics.html", u"レイヤー");

	auto window = asd::Window_Imp::Create(640, 480, asd::ToAString(u"レイヤー").c_str(), log, false, asd::WindowPositionType::Default, isOpenGLMode ? asd::GraphicsDeviceType::OpenGL : asd::GraphicsDeviceType::DirectX11, asd::ColorSpaceType::LinearSpace, false);
	ASSERT_TRUE(window != nullptr);

	auto synchronizer = std::make_shared<asd::Synchronizer>();
	auto file = asd::File_Imp::Create(synchronizer);
	ASSERT_TRUE(file != nullptr);

	asd::GraphicsOption go;
	go.IsFullScreen = false;
	go.IsReloadingEnabled = false;
	go.ColorSpace = asd::ColorSpaceType::LinearSpace;
	go.GraphicsDevice = isOpenGLMode ? asd::GraphicsDeviceType::OpenGL : asd::GraphicsDeviceType::DirectX11;
	auto graphics = asd::Graphics_Imp::Create(window, isOpenGLMode ? asd::GraphicsDeviceType::OpenGL : asd::GraphicsDeviceType::DirectX11, log, file, go);
	ASSERT_TRUE(graphics != nullptr);

	auto renderer = new asd::LayerRenderer(graphics);
	ASSERT_TRUE(renderer != nullptr);

	auto texture = graphics->CreateTexture2D(asd::ToAString(u"Data/Texture/Sample1.png").c_str());
	ASSERT_TRUE(texture != nullptr);

	int32_t time = 0;
	while (window->DoEvent())
	{
		graphics->Begin();
		graphics->Clear(true, false, asd::Color(0, 0, 0, 255));

		{
			asd::Vector2DF lpos[4];
			lpos[0].X = 0;
			lpos[0].Y = 0;
			lpos[1].X = 600;
			lpos[1].Y = 0;
			lpos[2].X = 640;
			lpos[2].Y = 480;
			lpos[3].X = 0;
			lpos[3].Y = 440;
			renderer->SetWindowSize(asd::Vector2DI(640, 480));
			renderer->SetTexture(texture.get());
			renderer->SetLayerPosition(lpos);
		}

		{
			asd::Vector2DF positions[4];
			asd::Color colors[4];
			asd::Vector2DF uvs[4];

			colors[0] = asd::Color(255, 255, 255, 255);
			colors[1] = asd::Color(255, 255, 255, 255);
			colors[2] = asd::Color(255, 255, 255, 255);

			positions[0].X = 0.0f;
			positions[0].Y = 0.0f;
			positions[1].X = 1.0f;
			positions[1].Y = 0.0f;
			positions[2].X = 1.0f;
			positions[2].Y = 1.0f;


			uvs[0].X = 0;
			uvs[0].Y = 0;
			uvs[1].X = 1;
			uvs[1].Y = 0;
			uvs[2].X = 1;
			uvs[2].Y = 1;

			renderer->AddTriangle(positions, colors, uvs);
		}

		{
			asd::Vector2DF positions[4];
			asd::Color colors[4];
			asd::Vector2DF uvs[4];

			colors[0] = asd::Color(255, 255, 255, 255);
			colors[1] = asd::Color(255, 255, 255, 255);
			colors[2] = asd::Color(255, 255, 255, 255);

			positions[0].X = 0.0f;
			positions[0].Y = 0.0f;
			positions[1].X = 0.5f;
			positions[1].Y = 1.0f;
			positions[2].X = 0.0f;
			positions[2].Y = 0.5f;

			uvs[0].X = 0;
			uvs[0].Y = 0;
			uvs[1].X = 1;
			uvs[1].Y = 1;
			uvs[2].X = 0;
			uvs[2].Y = 1;

			renderer->AddTriangle(positions, colors, uvs);
		}
		

		renderer->DrawCache();
		renderer->ClearCache();

		graphics->Present();

		graphics->End();

		if (time == 10)
		{
			SAVE_SCREEN_SHOT(graphics, 0);
		}

		if (time == 11)
		{
			window->Close();
		}
		time++;
	}

	texture.reset();
	renderer->Release();
	graphics->Release();
	file->Release();
	window->Release();
	delete log;
}
void Graphics_Mesh(bool isOpenGLMode)
{
	StartGraphicsTest();
	SetGLEnable(isOpenGLMode);

	ace::Log* log = ace::Log_Imp::Create(L"graphics.html", L"メッシュ");

	auto window = ace::Window_Imp::Create(640, 480, ace::ToAString(L"メッシュ").c_str());
	ASSERT_TRUE(window != nullptr);

	auto graphics = ace::Graphics_Imp::Create(window, isOpenGLMode, log, false);
	ASSERT_TRUE(graphics != nullptr);

	auto renderer3d = new ace::Renderer3D(graphics);
	ASSERT_TRUE(renderer3d != nullptr);
	renderer3d->SetWindowSize(ace::Vector2DI(640, 480));

	auto mesh1 = CreateMesh(graphics);
	auto mesh2 = CreateMesh(graphics);
	auto deformer = CreateDeformer(graphics);
	auto animation = CreateAnimation();

	auto cameraObject = new ace::RenderedCameraObject3D(graphics);
	cameraObject->SetPosition(ace::Vector3DF(0, 0, 10));
	cameraObject->SetFocus(ace::Vector3DF(0, 0, 0));
	cameraObject->SetFieldOfView(20.0f);
	cameraObject->SetZNear(1.0f);
	cameraObject->SetZFar(20.0f);
	cameraObject->SetWindowSize(ace::Vector2DI(800, 600));

	auto meshObject1 = new ace::RenderedModelObject3D(graphics);
	meshObject1->AddMeshGroup();
	meshObject1->AddMesh(0, mesh1);
	
	meshObject1->SetPosition(ace::Vector3DF(1, 0, 0));
	meshObject1->SetRotation(ace::Vector3DF(20.0f, 20.0f, 0.0f));

	auto meshObject2 = new ace::RenderedModelObject3D(graphics);
	meshObject2->AddMeshGroup();
	meshObject2->AddMesh(0, mesh2);
	meshObject2->SetDeformer(0, deformer.get());
	meshObject2->SetPosition(ace::Vector3DF(-1, 0, 0));
	meshObject2->SetRotation(ace::Vector3DF(20.0f, 20.0f, 0.0f));
	meshObject2->AddAnimationClip(ace::ToAString("anime1").c_str(), animation.get());
	meshObject2->PlayAnimation(ace::ToAString("anime1").c_str());

	auto lightObject = new ace::RenderedDirectionalLightObject3D(graphics);
	lightObject->SetRotation(ace::Vector3DF(30, 160, 0));

	renderer3d->AddObject(cameraObject);
	renderer3d->AddObject(meshObject1);
	renderer3d->AddObject(meshObject2);
	renderer3d->AddObject(lightObject);

	auto renderer2d = new ace::Renderer2D_Imp(graphics, log, window->GetSize());


	int32_t time = 0;
	while (window->DoEvent())
	{
		graphics->Begin();
		graphics->Clear(true, false, ace::Color(0, 0, 0, 255));

		renderer3d->Flip();

		renderer3d->BeginRendering();
		ace::Sleep(100);
		renderer3d->EndRendering();

		graphics->SetRenderTarget(nullptr, nullptr);

		ace::Vector2DF positions[4];
		ace::Color colors[4];
		ace::Vector2DF uvs[4];

		colors[0] = ace::Color(255, 255, 255, 255);
		colors[1] = ace::Color(255, 255, 255, 255);
		colors[2] = ace::Color(255, 255, 255, 255);
		colors[3] = ace::Color(255, 255, 255, 255);

		positions[0].X = 0;
		positions[0].Y = 0;
		positions[1].X = 640;
		positions[1].Y = 0;
		positions[2].X = 640;
		positions[2].Y = 480;
		positions[3].X = 0;
		positions[3].Y = 480;

		uvs[0].X = 0;
		uvs[0].Y = 0;
		uvs[1].X = 1;
		uvs[1].Y = 0;
		uvs[2].X = 1;
		uvs[2].Y = 1;
		uvs[3].X = 0;
		uvs[3].Y = 1;

		renderer2d->AddSprite(positions, colors, uvs, renderer3d->GetRenderTarget(), ace::eAlphaBlend::ALPHA_BLEND_BLEND, 0);
		renderer2d->DrawCache();
		renderer2d->ClearCache();

		graphics->Present();

		graphics->End();

		if (time == 10)
		{
			SAVE_SCREEN_SHOT(graphics, 0);
		}

		if (time == 11)
		{
			window->Close();
		}
		time++;
	}

	meshObject1->Release();
	meshObject2->Release();

	cameraObject->Release();
	lightObject->Release();

	delete renderer2d;
	delete renderer3d;

	graphics->Release();

	window->Release();
	delete log;
}