Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
rtoumazet committed Oct 25, 2024
1 parent 042785f commit 93479a4
Show file tree
Hide file tree
Showing 10 changed files with 453 additions and 410 deletions.
1 change: 1 addition & 0 deletions saturnin/saturnin.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@
<ClInclude Include="src\video\opengl\opengl_common.h" />
<ClInclude Include="src\video\opengl\opengl_render.h" />
<ClInclude Include="src\video\opengl\opengl_shaders.h" />
<ClInclude Include="src\video\opengl\opengl_textures.h" />
<ClInclude Include="src\video\opengl\opengl_utilities.h" />
<ClInclude Include="src\video\texture.h" />
<ClInclude Include="src\video\vdp1_part.h" />
Expand Down
31 changes: 17 additions & 14 deletions saturnin/src/video/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@ void showRenderingWindow(core::EmulatorContext& state) {

if (state.opengl()->areFbosInitialized()) {
if (state.opengl()->render()->isThereSomethingToRender()) {
state.opengl()->generateTextures();
state.opengl()->texturing()->generateTextures();
state.opengl()->render()->renderSelector();
}
const auto alpha = 0xff;
Expand Down Expand Up @@ -1477,9 +1477,10 @@ void showDebugVdp1Window(core::EmulatorContext& state, bool* opened) {

static auto opengl_id = 0;
if (texture) {
if (opengl_id != 0) { state.opengl()->deleteTexture(opengl_id); }
opengl_id
= state.opengl()->generateTexture((*texture)->width(), (*texture)->height(), (*texture)->rawData());
if (opengl_id != 0) { state.opengl()->texturing()->deleteTexture(opengl_id); }
opengl_id = state.opengl()->texturing()->generateTexture((*texture)->width(),
(*texture)->height(),
(*texture)->rawData());
ImGui::Image(reinterpret_cast<ImTextureID>(static_cast<uptr>(opengl_id)), preview_size);
}
}
Expand Down Expand Up @@ -1740,7 +1741,7 @@ void showDebugVdp2Window(core::EmulatorContext& state, bool* opened) {
if (state.vdp2()->screenInDebug() != video::ScrollScreen::none) {
state.opengl()->render()->renderVdp2DebugLayer(state);
}
const auto tex_id = state.opengl()->vdp2DebugLayerTextureId();
const auto tex_id = state.opengl()->texturing()->vdp2DebugLayerTextureId();
const auto preview_size = ImVec2(500, 500);
ImGui::Image(reinterpret_cast<ImTextureID>(static_cast<uptr>(tex_id)), preview_size);
} else {
Expand Down Expand Up @@ -1841,7 +1842,7 @@ void showDebugTexturesWindow(core::EmulatorContext& state, bool* opened) {

if (!keys_list.empty()) {
const auto& texture_key = keys_list[current_texture_idx].second;
ImGui::TextUnformatted(state.opengl()->getOpenglTextureDetails(texture_key).c_str());
ImGui::TextUnformatted(state.opengl()->texturing()->getOpenglTextureDetails(texture_key).c_str());
}
ImGui::EndChild();

Expand All @@ -1859,10 +1860,10 @@ void showDebugTexturesWindow(core::EmulatorContext& state, bool* opened) {
// Reloading texture data from the new selected entry.
const auto texture = video::Texture::getTexture(texture_key);
if (texture) {
if (opengl_id != 0) { state.opengl()->deleteTexture(opengl_id); }
opengl_id = state.opengl()->generateTexture((*texture)->width(),
(*texture)->height(),
(*texture)->rawData());
if (opengl_id != 0) { state.opengl()->texturing()->deleteTexture(opengl_id); }
opengl_id = state.opengl()->texturing()->generateTexture((*texture)->width(),
(*texture)->height(),
(*texture)->rawData());
}
previous_texture_idx = current_texture_idx;
}
Expand All @@ -1874,10 +1875,11 @@ void showDebugTexturesWindow(core::EmulatorContext& state, bool* opened) {
{
// Full layer display
const auto& key = keys_list[current_texture_idx].second;
const auto opengl_tex = state.opengl()->getOpenglTexture(key);
const auto opengl_tex = state.opengl()->texturing()->getOpenglTexture(key);

auto tex_id = state.opengl()->generateTextureFromTextureArrayLayer(video::GuiTextureType::layer_buffer,
static_cast<u8>(key));
auto tex_id
= state.opengl()->texturing()->generateTextureFromTextureArrayLayer(video::GuiTextureType::layer_buffer,
static_cast<u8>(key));
ImGui::SetCursorPos(layer_window_pos);
const auto child_size = ImVec2(area_3_width, ImGui::GetContentRegionAvail().y);
ImGui::BeginChild("ChildTextureLayer", child_size, false, window_flags);
Expand All @@ -1900,7 +1902,8 @@ void showDebugTexturesWindow(core::EmulatorContext& state, bool* opened) {
static auto current_layer = int{};
if (ImGui::Combo("Layer", &current_layer, layers)) {}
auto tex_id
= state.opengl()->generateTextureFromTextureArrayLayer(video::GuiTextureType::layer_buffer, current_layer);
= state.opengl()->texturing()->generateTextureFromTextureArrayLayer(video::GuiTextureType::layer_buffer,
current_layer);

ImGui::BeginChild("child_part_texture", child_size, true, window_flags);
const auto preview_size = ImVec2(500, 500);
Expand Down
Loading

0 comments on commit 93479a4

Please sign in to comment.