Skip to content

Instantly share code, notes, and snippets.

@voidproc
Created September 11, 2016 02:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save voidproc/f6047e8eb0e1797041fe2f92e36900a2 to your computer and use it in GitHub Desktop.
Save voidproc/f6047e8eb0e1797041fe2f92e36900a2 to your computer and use it in GitHub Desktop.
Circle::drawFrame + RenderTexture
#include <Siv3D.hpp>
void Main()
{
const Size windowSize(640, 480);
const Color bg = Palette::Black;
RenderTexture renderTexture(windowSize.x / 2, windowSize.y, bg);
Window::Resize(windowSize);
Graphics::SetBackground(bg);
Graphics2D::SetSamplerState(SamplerState::ClampLinear);
while (System::Update())
{
PutText(L"RenderTexture").at(windowSize.x * 3 / 4, 50);
PutText(L"Default").at(windowSize.x * 1 / 4, 50);
// (1) RenderTexture
Graphics2D::SetRenderTarget(renderTexture);
Rect(renderTexture.size).draw(bg); // 背景をクリア
Circle(windowSize.x / 4.0, windowSize.y / 2.0, 100.0).drawFrame(5.0, 0.0);
Circle(windowSize.x / 4.0, windowSize.y / 2.0, 70.0).draw();
Graphics2D::SetRenderTarget(Graphics::GetSwapChainTexture());
renderTexture.draw(windowSize.x / 2, 0);
// (2) Default
Circle(windowSize.x / 4.0 + Random(-100, 100), windowSize.y / 2.0, 100.0).drawFrame(5.0);
Circle(windowSize.x / 4.0, windowSize.y / 2.0, 70.0).draw();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment