Fix parallel-rdp integration and reset whole state upon loading rom

This commit is contained in:
CocoSimone
2022-08-13 11:44:35 +02:00
parent ed34d9c9ba
commit e2313c212c
41 changed files with 250 additions and 92 deletions

View File

@@ -9,35 +9,35 @@ void App::Run() {
SDL_Event event;
while (SDL_PollEvent(&event)) {
//ImGui_ImplSDL2_ProcessEvent(&event);
if (event.type == SDL_QUIT)
done = true;
if (window.gotClosed(event))
done = true;
if(event.type == SDL_KEYDOWN) {
switch(event.key.keysym.sym) {
case SDLK_o: {
nfdchar_t* outpath;
const nfdu8filteritem_t filter {"Nintendo 64 roms", "n64,z64,v64,N64,Z64,V64"};
nfdresult_t result = NFD_OpenDialog(&outpath, &filter, 1, nullptr);
if(result == NFD_OKAY) {
core.LoadROM(outpath);
NFD_FreePath(outpath);
}
switch(event.type) {
case SDL_QUIT: done = true; break;
case SDL_WINDOWEVENT:
done = window.gotClosed(event);
break;
case SDL_KEYDOWN:
switch(event.key.keysym.sym) {
case SDLK_o: {
nfdchar_t* outpath;
const nfdu8filteritem_t filter {"Nintendo 64 roms", "n64,z64,v64,N64,Z64,V64"};
nfdresult_t result = NFD_OpenDialog(&outpath, &filter, 1, nullptr);
if(result == NFD_OKAY) {
core.LoadROM(outpath);
NFD_FreePath(outpath);
}
} break;
} break;
}
}
core.PollInputs(event);
}
if(core.romLoaded)
core.Run();
if(core.romLoaded)
if(core.romLoaded) {
core.Run(window);
UpdateScreenParallelRdp(window, core.GetVI());
else
} else {
UpdateScreenParallelRdpNoGame(window);
}
SDL_Delay(16);
SDL_Delay(1);
}
}

View File

@@ -1,5 +1,4 @@
#pragma once
#include <Core.hpp>
#include <imgui/Window.hpp>
struct App {

View File

@@ -12,8 +12,7 @@ Window::Window(n64::Core& core) {
}
[[nodiscard]] bool Window::gotClosed(SDL_Event event) {
return event.type == SDL_WINDOWEVENT
&& event.window.event == SDL_WINDOWEVENT_CLOSE
return event.window.event == SDL_WINDOWEVENT_CLOSE
&& event.window.windowID == SDL_GetWindowID(window);
}
@@ -177,18 +176,18 @@ Window::~Window() {
vkDestroyInstance(instance, nullptr);
}
ImDrawData* Window::Present() {
ImDrawData* Window::Present(n64::Core& core) {
//ImGui_ImplVulkan_NewFrame();
//ImGui_ImplSDL2_NewFrame(window);
//ImGui::NewFrame();
//
Render();
Render(core);
//ImGui::Render();
return ImGui::GetDrawData();
}
void Window::Render() {
void Window::Render(n64::Core& core) {
ImGui::BeginMainMenuBar();
if(ImGui::BeginMenu("File")) {
if(ImGui::BeginMenu("Open")) {

View File

@@ -10,15 +10,14 @@
struct Window {
explicit Window(n64::Core& core);
~Window();
ImDrawData* Present();
ImDrawData* Present(n64::Core& core);
[[nodiscard]] bool gotClosed(SDL_Event event);
private:
SDL_Window* window;
n64::Core core;
void InitSDL();
void InitImgui();
void Render();
void Render(n64::Core& core);
VkInstance instance{};
VkPhysicalDevice physicalDevice{};