Skip to content

Commit ec5247f

Browse files
committed
[GUI] Cleaning up more GL code.
1 parent a037e9e commit ec5247f

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

src/gui/gui.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,8 @@ end)(jit.status()))
466466
m_biosEditor.title = []() { return _("BIOS"); };
467467
m_biosEditor.show = false;
468468

469+
m_offscreenShaderEditor.init();
470+
m_outputShaderEditor.init();
469471
m_offscreenShaderEditor.compile(this);
470472
m_outputShaderEditor.compile(this);
471473

@@ -647,6 +649,7 @@ void PCSX::GUI::flip() {
647649
}
648650

649651
void PCSX::GUI::endFrame() {
652+
constexpr float renderRatio = 3.0f / 4.0f;
650653
auto& io = ImGui::GetIO();
651654
// bind back the output frame buffer
652655
glBindFramebuffer(GL_FRAMEBUFFER, 0);
@@ -656,7 +659,7 @@ void PCSX::GUI::endFrame() {
656659
int w, h;
657660
glfwGetFramebufferSize(m_window, &w, &h);
658661
m_renderSize = ImVec2(w, h);
659-
normalizeDimensions(m_renderSize, m_renderRatio);
662+
normalizeDimensions(m_renderSize, renderRatio);
660663

661664
bool changed = false;
662665

@@ -689,7 +692,7 @@ void PCSX::GUI::endFrame() {
689692
_("Output"), &outputShown,
690693
ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse | ImGuiWindowFlags_NoCollapse)) {
691694
ImVec2 textureSize = ImGui::GetContentRegionAvail();
692-
normalizeDimensions(textureSize, m_renderRatio);
695+
normalizeDimensions(textureSize, renderRatio);
693696
ImTextureID texture = reinterpret_cast<ImTextureID*>(m_offscreenTextures[m_currentTexture]);
694697
m_outputShaderEditor.renderWithImgui(this, texture, m_renderSize, textureSize);
695698
}

src/gui/gui.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ class GUI final {
200200
ImVec4 m_backgroundColor = ImColor(114, 144, 154);
201201
ImVec2 m_renderSize = ImVec2(1, 1);
202202

203-
float m_renderRatio = 3.0f / 4.0f;
204203
bool &m_fullscreen = {settings.get<Fullscreen>().value};
205204

206205
// GUI

src/gui/widgets/shader-editor.cc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,11 @@ void PCSX::Widgets::ShaderEditor::setDefaults() {
162162
m_luaEditor.setText(c_defaultLuaInvoker);
163163
}
164164

165+
void PCSX::Widgets::ShaderEditor::init() {
166+
glGenVertexArrays(1, &m_vao);
167+
glGenBuffers(1, &m_vbo);
168+
}
169+
165170
std::optional<GLuint> PCSX::Widgets::ShaderEditor::compile(GUI *gui,
166171
const std::vector<std::string_view> &mandatoryAttributes) {
167172
GLint status = 0;
@@ -698,13 +703,7 @@ void PCSX::Widgets::ShaderEditor::render(GUI *gui, GLuint textureID, const ImVec
698703
return;
699704
}
700705

701-
if (m_vao == 0) {
702-
glGenVertexArrays(1, &m_vao);
703-
glGenBuffers(1, &m_vbo);
704-
}
705-
706706
glBindVertexArray(m_vao);
707-
708707
glUseProgram(m_shaderProgram);
709708
struct VertexData {
710709
float positions[3];

src/gui/widgets/shader-editor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class ShaderEditor {
5252
}
5353

5454
void setDefaults();
55+
void init();
5556
void reset(GUI*);
5657

5758
bool draw(GUI*, const char* title);

0 commit comments

Comments
 (0)