Skip to content

Commit a037e9e

Browse files
committed
[GUI] Clean up some GL code.
1 parent afea3b1 commit a037e9e

File tree

4 files changed

+5
-13
lines changed

4 files changed

+5
-13
lines changed

src/gpu/soft/draw.cc

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,13 @@ void ShowGunCursor(unsigned char *surf) {
193193
static GLuint vramTexture = 0;
194194

195195
void DoBufferSwap() {
196+
GLuint textureID = m_gui->getVRAMTexture();
196197
m_gui->setViewport();
197-
m_gui->bindVRAMTexture();
198+
glBindTexture(GL_TEXTURE_2D, textureID);
198199
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 1024, 512, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, psxVuw);
199200

200201
if (PSXDisplay.RGB24) {
202+
textureID = vramTexture;
201203
glBindTexture(GL_TEXTURE_2D, vramTexture);
202204
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 682, 512, GL_RGB, GL_UNSIGNED_BYTE, psxVuw);
203205
}
@@ -214,13 +216,8 @@ void DoBufferSwap() {
214216
float width = (PSXDisplay.DisplayEnd.x - PSXDisplay.DisplayPosition.x) / 1024.0f;
215217
float height = (PSXDisplay.DisplayEnd.y - PSXDisplay.DisplayPosition.y) / 512.0f;
216218

217-
GLint textureID;
218-
219-
glGetIntegerv(GL_TEXTURE_BINDING_2D, &textureID);
220219
m_gui->m_offscreenShaderEditor.render(m_gui, textureID, {1024.0f, 512.0f}, {startX, startY}, {width, height},
221220
m_gui->getRenderSize());
222-
223-
glBindTexture(GL_TEXTURE_2D, 0);
224221
m_gui->flip();
225222
}
226223

src/gui/gui.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -638,8 +638,6 @@ void PCSX::GUI::flip() {
638638

639639
assert(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE);
640640

641-
glViewport(0, 0, m_renderSize.x, m_renderSize.y);
642-
643641
glClearColor(0, 0, 0, 0);
644642
glClearDepthf(0.f);
645643
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

src/gui/gui.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ class GUI final {
9999
void update(bool vsync = false);
100100
void flip();
101101
void bindVRAMTexture();
102+
GLuint getVRAMTexture() { return m_VRAMTexture; }
102103
void setViewport();
103104
void setFullscreen(bool);
104105
bool addLog(LogClass logClass, const std::string &msg) {
@@ -189,7 +190,7 @@ class GUI final {
189190
int &m_glfwPosY = settings.get<WindowPosY>().value;
190191
int &m_glfwSizeX = settings.get<WindowSizeX>().value;
191192
int &m_glfwSizeY = settings.get<WindowSizeY>().value;
192-
unsigned int m_VRAMTexture = 0;
193+
GLuint m_VRAMTexture = 0;
193194

194195
unsigned int m_offscreenFrameBuffer = 0;
195196
unsigned int m_offscreenTextures[2] = {0, 0};

src/gui/widgets/shader-editor.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -874,8 +874,4 @@ void PCSX::Widgets::ShaderEditor::render(GUI *gui, GLuint textureID, const ImVec
874874
}
875875

876876
glDrawArrays(GL_TRIANGLES, 0, 6);
877-
878-
glUseProgram(0);
879-
glBindVertexArray(0);
880-
glBindBuffer(GL_ARRAY_BUFFER, 0);
881877
}

0 commit comments

Comments
 (0)