示例#1
0
文件: Test2D.cpp 项目: Xeryko/Sparky
void Test2D::OnInit(Renderer2D& renderer, Material& material)
{
	// m_Window->SetVsync(false);
	m_Renderer = &renderer;

	renderer.SetRenderTarget(RenderTarget::SCREEN);
	//renderer.AddPostEffectsPass(new PostEffectsPass(Shader::CreateFromFile("Horizontal Blur", "shaders/postfx.shader")));
	//renderer.SetPostEffects(false);

	TextureParameters params(TextureFilter::NEAREST);
	Add(spnew Sprite(4.0f, 4.0f, 4, 4, Texture2D::CreateFromFile("Tex", "res/tb.png", params)));
	Add(spnew Sprite(-5.0f, -5.0f, 3, 3, 0xffff00ff));

	FontManager::Add(spnew Font("Consolas", "res/consola.ttf", 96));
	FontManager::Add(spnew Font("Brush Script", "res/BrushScriptStd.otf", 96));

	m_DebugInfo = spnew Label*[10];
	Add(m_DebugInfo[0] = spnew Label("", -15.5f, 8.5f, 0xffffffff));
	Add(m_DebugInfo[1] = spnew Label("", -15.5f, 7.5f, 0xffffffff));
	Add(m_DebugInfo[2] = spnew Label("", -15.5f, 6.5f, 0xffffffff));
	Add(m_DebugInfo[3] = spnew Label("", -15.5f, 5.5f, 0xffffffff));
	Add(m_DebugInfo[4] = spnew Label("", -15.5f, 4.5f, 0xffffffff));

	Add(spnew Label("Consolas", -15.5f, 0.0f, FontManager::Get("Consolas"), 0xffffffff));
	Add(spnew Label("Brush Script", -15.5f, 2.0f, FontManager::Get("Brush Script"), 0xffffffff));

	Texture::SetWrap(TextureWrap::CLAMP_TO_BORDER);
	Mask* mask = spnew Mask(Texture2D::CreateFromFile("Mask", "res/mask.png"));
	mask->transform = mat4::Translate(vec3(-16.0f, -9.0f, 0.0f)) * mat4::Scale(vec3(32, 18, 1));
	SetMask(mask);
}
示例#2
0
void TestLayer::OnInit(Renderer2D& renderer, Shader& shader)
{
	// m_Window->SetVsync(false);
	m_Renderer = &renderer;

	renderer.SetRenderTarget(RenderTarget::BUFFER);
	renderer.AddPostEffectsPass(new PostEffectsPass(Shader::FromFile("Horizontal Blur", "shaders/postfx.shader")));
	renderer.SetPostEffects(false);

	Texture::SetFilter(TextureFilter::NEAREST);
	Add(new Sprite(0.0f, 0.0f, 8, 8, new Texture("Tex", "res/tb.png")));
	Add(new Sprite(-8.0f, -8.0f, 6, 6, 0xffff00ff));

	debugInfo = new Label*[10];
	debugInfo[0] = new Label("", -15.5f, 6.8f, 0xffffffff);
	debugInfo[1] = new Label("", -15.5f, 5.8f, 0xffffffff);
	Add(debugInfo[0]);
	Add(debugInfo[1]);

	Texture::SetWrap(TextureWrap::CLAMP_TO_BORDER);
	Mask* mask = new Mask(new Texture("Mask", "res/mask.png"));
	mask->transform = mat4::Translate(vec3(-16.0f, -9.0f, 0.0f)) * mat4::Scale(vec3(32, 18, 1));
	SetMask(mask);
}