mirror of
https://github.com/wiiu-env/ftpiiu_plugin.git
synced 2024-12-23 11:21:49 +01:00
Use anti-aliasing framebuffer on 3DS
This commit is contained in:
parent
34c6d61215
commit
2da46d407f
@ -43,7 +43,7 @@ constexpr auto CLEAR_COLOR = 0x204B7AFF;
|
|||||||
constexpr auto DISPLAY_TRANSFER_FLAGS =
|
constexpr auto DISPLAY_TRANSFER_FLAGS =
|
||||||
GX_TRANSFER_FLIP_VERT (0) | GX_TRANSFER_OUT_TILED (0) | GX_TRANSFER_RAW_COPY (0) |
|
GX_TRANSFER_FLIP_VERT (0) | GX_TRANSFER_OUT_TILED (0) | GX_TRANSFER_RAW_COPY (0) |
|
||||||
GX_TRANSFER_IN_FORMAT (GX_TRANSFER_FMT_RGBA8) | GX_TRANSFER_OUT_FORMAT (GX_TRANSFER_FMT_RGB8) |
|
GX_TRANSFER_IN_FORMAT (GX_TRANSFER_FMT_RGBA8) | GX_TRANSFER_OUT_FORMAT (GX_TRANSFER_FMT_RGB8) |
|
||||||
GX_TRANSFER_SCALING (GX_TRANSFER_SCALE_NO);
|
GX_TRANSFER_SCALING (GX_TRANSFER_SCALE_XY);
|
||||||
|
|
||||||
/// \brief Top screen render target
|
/// \brief Top screen render target
|
||||||
C3D_RenderTarget *s_top = nullptr;
|
C3D_RenderTarget *s_top = nullptr;
|
||||||
@ -175,11 +175,11 @@ void imgui::citro3d::init ()
|
|||||||
C3D_Init (C3D_DEFAULT_CMDBUF_SIZE);
|
C3D_Init (C3D_DEFAULT_CMDBUF_SIZE);
|
||||||
|
|
||||||
// create top screen render target
|
// create top screen render target
|
||||||
s_top = C3D_RenderTargetCreate (240, 400, GPU_RB_RGBA8, GPU_RB_DEPTH24_STENCIL8);
|
s_top = C3D_RenderTargetCreate (480, 800, GPU_RB_RGBA8, GPU_RB_DEPTH24_STENCIL8);
|
||||||
C3D_RenderTargetSetOutput (s_top, GFX_TOP, GFX_LEFT, DISPLAY_TRANSFER_FLAGS);
|
C3D_RenderTargetSetOutput (s_top, GFX_TOP, GFX_LEFT, DISPLAY_TRANSFER_FLAGS);
|
||||||
|
|
||||||
// create bottom screen render target
|
// create bottom screen render target
|
||||||
s_bottom = C3D_RenderTargetCreate (240, 320, GPU_RB_RGBA8, GPU_RB_DEPTH24_STENCIL8);
|
s_bottom = C3D_RenderTargetCreate (480, 640, GPU_RB_RGBA8, GPU_RB_DEPTH24_STENCIL8);
|
||||||
C3D_RenderTargetSetOutput (s_bottom, GFX_BOTTOM, GFX_LEFT, DISPLAY_TRANSFER_FLAGS);
|
C3D_RenderTargetSetOutput (s_bottom, GFX_BOTTOM, GFX_LEFT, DISPLAY_TRANSFER_FLAGS);
|
||||||
|
|
||||||
// load vertex shader
|
// load vertex shader
|
||||||
@ -195,8 +195,8 @@ void imgui::citro3d::init ()
|
|||||||
s_projLocation = shaderInstanceGetUniformLocation (s_program.vertexShader, "proj");
|
s_projLocation = shaderInstanceGetUniformLocation (s_program.vertexShader, "proj");
|
||||||
|
|
||||||
// initialize projection matrices
|
// initialize projection matrices
|
||||||
Mtx_OrthoTilt (&s_projTop, 0.0f, 800.0f, 480.0f, 0.0f, -1.0f, 1.0f, false);
|
Mtx_OrthoTilt (&s_projTop, 0.0f, 400.0f, 240.0f, 0.0f, -1.0f, 1.0f, false);
|
||||||
Mtx_OrthoTilt (&s_projBottom, 80.0f, 720.0f, 960.0f, 480.0f, -1.0f, 1.0f, false);
|
Mtx_OrthoTilt (&s_projBottom, 40.0f, 360.0f, 480.0f, 240.0f, -1.0f, 1.0f, false);
|
||||||
|
|
||||||
// allocate vertex data buffer
|
// allocate vertex data buffer
|
||||||
s_vtxSize = 65536;
|
s_vtxSize = 65536;
|
||||||
@ -397,13 +397,13 @@ void imgui::citro3d::init ()
|
|||||||
|
|
||||||
// finalize font
|
// finalize font
|
||||||
imFont->DisplayOffset.x = 0.0f;
|
imFont->DisplayOffset.x = 0.0f;
|
||||||
imFont->DisplayOffset.y = fontInfo->ascent;
|
imFont->DisplayOffset.y = fontInfo->ascent * 0.5f;
|
||||||
imFont->ContainerAtlas = atlas;
|
imFont->ContainerAtlas = atlas;
|
||||||
imFont->ConfigData = &atlas->ConfigData[0];
|
imFont->ConfigData = &atlas->ConfigData[0];
|
||||||
imFont->ConfigDataCount = 1;
|
imFont->ConfigDataCount = 1;
|
||||||
imFont->FallbackChar = alterChar;
|
imFont->FallbackChar = alterChar;
|
||||||
imFont->EllipsisChar = config.EllipsisChar;
|
imFont->EllipsisChar = config.EllipsisChar;
|
||||||
imFont->Scale = s_textScale;
|
imFont->Scale = s_textScale * 0.5f;
|
||||||
imFont->Ascent = fontInfo->ascent;
|
imFont->Ascent = fontInfo->ascent;
|
||||||
imFont->Descent = 0.0f;
|
imFont->Descent = 0.0f;
|
||||||
}
|
}
|
||||||
@ -563,14 +563,16 @@ void imgui::citro3d::render ()
|
|||||||
if (screen == GFX_TOP)
|
if (screen == GFX_TOP)
|
||||||
{
|
{
|
||||||
// check if clip starts on bottom screen
|
// check if clip starts on bottom screen
|
||||||
if (clip.y > 240.0f)
|
if (clip.y > height * 0.5f)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// convert from framebuffer space to screen space (3DS screen rotation)
|
// convert from framebuffer space to screen space (3DS screen rotation)
|
||||||
auto const x1 = std::clamp<unsigned> (240.0f - clip.w, 0, 240);
|
auto const x1 =
|
||||||
auto const y1 = std::clamp<unsigned> (400.0f - clip.z, 0, 400);
|
std::clamp<unsigned> (height * 0.5f - clip.w, 0, height * 0.5f);
|
||||||
auto const x2 = std::clamp<unsigned> (240.0f - clip.y, 0, 240);
|
auto const y1 = std::clamp<unsigned> (width - clip.z, 0, width);
|
||||||
auto const y2 = std::clamp<unsigned> (400.0f - clip.x, 0, 400);
|
auto const x2 =
|
||||||
|
std::clamp<unsigned> (height * 0.5f - clip.y, 0, height * 0.5f);
|
||||||
|
auto const y2 = std::clamp<unsigned> (width - clip.x, 0, width);
|
||||||
|
|
||||||
// check if scissor needs to be updated
|
// check if scissor needs to be updated
|
||||||
if (s_boundScissor[0] != x1 || s_boundScissor[1] != y1 ||
|
if (s_boundScissor[0] != x1 || s_boundScissor[1] != y1 ||
|
||||||
@ -586,23 +588,25 @@ void imgui::citro3d::render ()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// check if clip ends on top screen
|
// check if clip ends on top screen
|
||||||
if (clip.w < 240.0f)
|
if (clip.w < height * 0.5f)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// check if clip ends before left edge of bottom screen
|
// check if clip ends before left edge of bottom screen
|
||||||
if (clip.z < 40.0f)
|
if (clip.z < width * 0.1f)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// check if clip starts after right edge of bottom screen
|
// check if clip starts after right edge of bottom screen
|
||||||
if (clip.x > 360.0f)
|
if (clip.x > width * 0.9f)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// convert from framebuffer space to screen space
|
// convert from framebuffer space to screen space
|
||||||
// (3DS screen rotation + bottom screen offset)
|
// (3DS screen rotation + bottom screen offset)
|
||||||
auto const x1 = std::clamp<unsigned> (480.0f - clip.w, 0, 240);
|
auto const x1 = std::clamp<unsigned> (height - clip.w, 0, height * 0.5f);
|
||||||
auto const y1 = std::clamp<unsigned> (360.0f - clip.z, 0, 320);
|
auto const y1 =
|
||||||
auto const x2 = std::clamp<unsigned> (480.0f - clip.y, 0, 240);
|
std::clamp<unsigned> (width * 0.9f - clip.z, 0, width * 0.8f);
|
||||||
auto const y2 = std::clamp<unsigned> (360.0f - clip.x, 0, 320);
|
auto const x2 = std::clamp<unsigned> (height - clip.y, 0, height * 0.5f);
|
||||||
|
auto const y2 =
|
||||||
|
std::clamp<unsigned> (width * 0.9f - clip.x, 0, width * 0.8f);
|
||||||
|
|
||||||
// check if scissor needs to be updated
|
// check if scissor needs to be updated
|
||||||
if (s_boundScissor[0] != x1 || s_boundScissor[1] != y1 ||
|
if (s_boundScissor[0] != x1 || s_boundScissor[1] != y1 ||
|
||||||
|
@ -168,8 +168,8 @@ void imgui::ctru::newFrame ()
|
|||||||
"to renderer _NewFrame() function?");
|
"to renderer _NewFrame() function?");
|
||||||
|
|
||||||
// setup display metrics
|
// setup display metrics
|
||||||
io.DisplaySize = ImVec2 (SCREEN_WIDTH * 2.0f, SCREEN_HEIGHT * 2.0f);
|
io.DisplaySize = ImVec2 (SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||||
io.DisplayFramebufferScale = ImVec2 (0.5f, 0.5f);
|
io.DisplayFramebufferScale = ImVec2 (2.0f, 2.0f);
|
||||||
|
|
||||||
// time step
|
// time step
|
||||||
static auto const start = platform::steady_clock::now ();
|
static auto const start = platform::steady_clock::now ();
|
||||||
|
@ -97,8 +97,8 @@ void drawLogo ()
|
|||||||
ImGuiIO &io = ImGui::GetIO ();
|
ImGuiIO &io = ImGui::GetIO ();
|
||||||
auto const screenWidth = io.DisplaySize.x;
|
auto const screenWidth = io.DisplaySize.x;
|
||||||
auto const screenHeight = io.DisplaySize.y;
|
auto const screenHeight = io.DisplaySize.y;
|
||||||
auto const logoWidth = subTex->width / io.DisplayFramebufferScale.x;
|
auto const logoWidth = subTex->width;
|
||||||
auto const logoHeight = subTex->height / io.DisplayFramebufferScale.y;
|
auto const logoHeight = subTex->height;
|
||||||
|
|
||||||
// calculate top screen coords
|
// calculate top screen coords
|
||||||
auto const x1 = (screenWidth - logoWidth) / 2.0f;
|
auto const x1 = (screenWidth - logoWidth) / 2.0f;
|
||||||
@ -160,8 +160,8 @@ void drawStatus ()
|
|||||||
// calculate battery icon metrics
|
// calculate battery icon metrics
|
||||||
auto const battery =
|
auto const battery =
|
||||||
Tex3DS_GetSubTexture (s_gfxT3x, charging ? gfx_batteryCharge_idx : batteryLevels[level]);
|
Tex3DS_GetSubTexture (s_gfxT3x, charging ? gfx_batteryCharge_idx : batteryLevels[level]);
|
||||||
auto const batteryWidth = battery->width / io.DisplayFramebufferScale.x;
|
auto const batteryWidth = battery->width;
|
||||||
auto const batteryHeight = battery->height / io.DisplayFramebufferScale.y;
|
auto const batteryHeight = battery->height;
|
||||||
|
|
||||||
// calculate battery icon position
|
// calculate battery icon position
|
||||||
auto const p1 = ImVec2 (screenWidth - batteryWidth, 0.0f);
|
auto const p1 = ImVec2 (screenWidth - batteryWidth, 0.0f);
|
||||||
@ -179,12 +179,12 @@ void drawStatus ()
|
|||||||
|
|
||||||
// calculate wifi icon metrics
|
// calculate wifi icon metrics
|
||||||
auto const wifi = Tex3DS_GetSubTexture (s_gfxT3x, wifiLevels[wifiStrength]);
|
auto const wifi = Tex3DS_GetSubTexture (s_gfxT3x, wifiLevels[wifiStrength]);
|
||||||
auto const wifiWidth = wifi->width / io.DisplayFramebufferScale.x;
|
auto const wifiWidth = wifi->width;
|
||||||
auto const wifiHeight = wifi->height / io.DisplayFramebufferScale.y;
|
auto const wifiHeight = wifi->height;
|
||||||
|
|
||||||
// calculate wifi icon position
|
// calculate wifi icon position
|
||||||
auto const p3 = ImVec2 (p1.x - wifiWidth - 4.0f, 0.0f);
|
auto const p3 = ImVec2 (p1.x - wifiWidth - 2.0f, 0.0f);
|
||||||
auto const p4 = ImVec2 (p1.x - 4.0f, wifiHeight);
|
auto const p4 = ImVec2 (p1.x - 2.0f, wifiHeight);
|
||||||
|
|
||||||
// calculate wifi icon uv coords
|
// calculate wifi icon uv coords
|
||||||
auto const uv3 = ImVec2 (wifi->left, wifi->top);
|
auto const uv3 = ImVec2 (wifi->left, wifi->top);
|
||||||
@ -198,7 +198,7 @@ void drawStatus ()
|
|||||||
auto const now = std::time (nullptr);
|
auto const now = std::time (nullptr);
|
||||||
std::strftime (buffer, sizeof (buffer), "%H:%M:%S", std::localtime (&now));
|
std::strftime (buffer, sizeof (buffer), "%H:%M:%S", std::localtime (&now));
|
||||||
ImGui::GetForegroundDrawList ()->AddText (
|
ImGui::GetForegroundDrawList ()->AddText (
|
||||||
ImVec2 (p3.x - 130.0f, style.FramePadding.y), 0xFFFFFFFF, buffer);
|
ImVec2 (p3.x - 65.0f, style.FramePadding.y), 0xFFFFFFFF, buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,6 +237,11 @@ bool platform::init ()
|
|||||||
C3D_TexSetFilter (&s_gfxTexture, GPU_LINEAR, GPU_LINEAR);
|
C3D_TexSetFilter (&s_gfxTexture, GPU_LINEAR, GPU_LINEAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// citro3d logo doesn't quite show with the default transparency
|
||||||
|
auto &style = ImGui::GetStyle ();
|
||||||
|
style.Colors[ImGuiCol_WindowBg].w = 0.8f;
|
||||||
|
style.ScaleAllSizes (0.5f);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,10 +302,7 @@ void FtpSession::draw ()
|
|||||||
{
|
{
|
||||||
auto const lock = std::scoped_lock (m_lock);
|
auto const lock = std::scoped_lock (m_lock);
|
||||||
|
|
||||||
ImGuiIO &io = ImGui::GetIO ();
|
ImGui::BeginChild (m_windowName.c_str (), ImVec2 (0.0f, 50.0f), true);
|
||||||
auto const scale = io.DisplayFramebufferScale.y;
|
|
||||||
|
|
||||||
ImGui::BeginChild (m_windowName.c_str (), ImVec2 (0.0f, 50.0f / scale), true);
|
|
||||||
|
|
||||||
if (!m_workItem.empty ())
|
if (!m_workItem.empty ())
|
||||||
ImGui::TextUnformatted (m_workItem.c_str ());
|
ImGui::TextUnformatted (m_workItem.c_str ());
|
||||||
@ -350,11 +347,8 @@ void FtpSession::draw ()
|
|||||||
auto const rateString = fs::printSize (m_xferRate) + "/s";
|
auto const rateString = fs::printSize (m_xferRate) + "/s";
|
||||||
|
|
||||||
ImGui::SameLine ();
|
ImGui::SameLine ();
|
||||||
ImGui::PlotLines ("Rate",
|
ImGui::PlotLines (
|
||||||
m_filePositionDeltas,
|
"", m_filePositionDeltas, IM_ARRAYSIZE (m_filePositionDeltas), 0, rateString.c_str ());
|
||||||
IM_ARRAYSIZE (m_filePositionDeltas),
|
|
||||||
0,
|
|
||||||
rateString.c_str ());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::EndChild ();
|
ImGui::EndChild ();
|
||||||
|
@ -41,11 +41,6 @@ int main (int argc_, char *argv_[])
|
|||||||
auto &style = ImGui::GetStyle ();
|
auto &style = ImGui::GetStyle ();
|
||||||
style.WindowRounding = 0.0f;
|
style.WindowRounding = 0.0f;
|
||||||
|
|
||||||
#ifdef _3DS
|
|
||||||
// citro3d logo doesn't quite show with the default transparency
|
|
||||||
style.Colors[ImGuiCol_WindowBg].w = 0.8f;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
auto server = FtpServer::create (5000);
|
auto server = FtpServer::create (5000);
|
||||||
|
|
||||||
while (platform::loop ())
|
while (platform::loop ())
|
||||||
@ -55,7 +50,9 @@ int main (int argc_, char *argv_[])
|
|||||||
platform::render ();
|
platform::render ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// clean up resources before exiting switch/3ds services
|
||||||
server.reset ();
|
server.reset ();
|
||||||
|
|
||||||
platform::exit ();
|
platform::exit ();
|
||||||
ImGui::DestroyContext ();
|
ImGui::DestroyContext ();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user