mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-12-14 07:36:59 +00:00
Add all the files
This commit is contained in:
parent
e3db07a16a
commit
d60742f52b
1445 changed files with 430238 additions and 0 deletions
64
src/gui/canvas/VulkanCanvas.cpp
Normal file
64
src/gui/canvas/VulkanCanvas.cpp
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
#include "gui/canvas/VulkanCanvas.h"
|
||||
#include "Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h"
|
||||
#include "gui/guiWrapper.h"
|
||||
|
||||
#include <wx/msgdlg.h>
|
||||
|
||||
VulkanCanvas::VulkanCanvas(wxWindow* parent, const wxSize& size, bool is_main_window)
|
||||
: IRenderCanvas(is_main_window), wxWindow(parent, wxID_ANY, wxDefaultPosition, size, wxFULL_REPAINT_ON_RESIZE | wxWANTS_CHARS)
|
||||
{
|
||||
Bind(wxEVT_PAINT, &VulkanCanvas::OnPaint, this);
|
||||
Bind(wxEVT_SIZE, &VulkanCanvas::OnResize, this);
|
||||
|
||||
if(is_main_window)
|
||||
gui_initHandleContextFromWxWidgetsWindow(gui_getWindowInfo().canvas_main, this);
|
||||
else
|
||||
gui_initHandleContextFromWxWidgetsWindow(gui_getWindowInfo().canvas_pad, this);
|
||||
|
||||
cemu_assert(g_vulkan_available);
|
||||
|
||||
try
|
||||
{
|
||||
if (is_main_window)
|
||||
g_renderer = std::make_unique<VulkanRenderer>();
|
||||
|
||||
auto vulkan_renderer = VulkanRenderer::GetInstance();
|
||||
vulkan_renderer->Initialize({size.x, size.y}, is_main_window);
|
||||
}
|
||||
catch(const std::exception& ex)
|
||||
{
|
||||
const auto msg = fmt::format(_("Error when initializing Vulkan renderer:\n{}").ToStdString(), ex.what());
|
||||
forceLog_printf(const_cast<char*>(msg.c_str()));
|
||||
wxMessageDialog dialog(this, msg, _("Error"), wxOK | wxCENTRE | wxICON_ERROR);
|
||||
dialog.ShowModal();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
wxWindow::EnableTouchEvents(wxTOUCH_PAN_GESTURES);
|
||||
}
|
||||
|
||||
VulkanCanvas::~VulkanCanvas()
|
||||
{
|
||||
Unbind(wxEVT_PAINT, &VulkanCanvas::OnPaint, this);
|
||||
Unbind(wxEVT_SIZE, &VulkanCanvas::OnResize, this);
|
||||
}
|
||||
|
||||
void VulkanCanvas::OnPaint(wxPaintEvent& event)
|
||||
{
|
||||
}
|
||||
|
||||
void VulkanCanvas::OnResize(wxSizeEvent& event)
|
||||
{
|
||||
const wxSize size = GetSize();
|
||||
if (size.GetWidth() == 0 || size.GetHeight() == 0)
|
||||
return;
|
||||
|
||||
const wxRect refreshRect(size);
|
||||
RefreshRect(refreshRect, false);
|
||||
|
||||
if (g_renderer == nullptr)
|
||||
return;
|
||||
|
||||
auto vulkan_renderer = VulkanRenderer::GetInstance();
|
||||
vulkan_renderer->ResizeSwapchain({ size.x, size.y }, m_is_main_window);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue