OGL: Update the window size after swapping buffers, not before
Prevents us from rendering beyond the viewport bounds.
This commit is contained in:
parent
73a67aa413
commit
ab44536a3c
|
@ -54,6 +54,7 @@ GLuint FramebufferManager::CreateTexture(GLenum texture_type, GLenum internal_fo
|
||||||
GLenum pixel_format, GLenum data_type)
|
GLenum pixel_format, GLenum data_type)
|
||||||
{
|
{
|
||||||
GLuint texture;
|
GLuint texture;
|
||||||
|
glActiveTexture(GL_TEXTURE9);
|
||||||
glGenTextures(1, &texture);
|
glGenTextures(1, &texture);
|
||||||
glBindTexture(texture_type, texture);
|
glBindTexture(texture_type, texture);
|
||||||
if (texture_type == GL_TEXTURE_2D_ARRAY)
|
if (texture_type == GL_TEXTURE_2D_ARRAY)
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include "Core/Config/GraphicsSettings.h"
|
#include "Core/Config/GraphicsSettings.h"
|
||||||
|
|
||||||
#include "VideoBackends/OGL/FramebufferManager.h"
|
#include "VideoBackends/OGL/FramebufferManager.h"
|
||||||
|
#include "VideoBackends/OGL/OGLTexture.h"
|
||||||
#include "VideoBackends/OGL/ProgramShaderCache.h"
|
#include "VideoBackends/OGL/ProgramShaderCache.h"
|
||||||
#include "VideoBackends/OGL/SamplerCache.h"
|
#include "VideoBackends/OGL/SamplerCache.h"
|
||||||
|
|
||||||
|
@ -121,6 +122,7 @@ void OpenGLPostProcessing::BlitFromTexture(TargetRectangle src, TargetRectangle
|
||||||
glBindTexture(GL_TEXTURE_2D_ARRAY, src_texture);
|
glBindTexture(GL_TEXTURE_2D_ARRAY, src_texture);
|
||||||
g_sampler_cache->BindLinearSampler(9);
|
g_sampler_cache->BindLinearSampler(9);
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
|
OGLTexture::SetStage();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenGLPostProcessing::ApplyShader()
|
void OpenGLPostProcessing::ApplyShader()
|
||||||
|
|
|
@ -1355,11 +1355,37 @@ void Renderer::SwapImpl(AbstractTexture* texture, const EFBRectangle& xfb_region
|
||||||
xfb_texture->GetConfig().width, xfb_texture->GetConfig().height);
|
xfb_texture->GetConfig().width, xfb_texture->GetConfig().height);
|
||||||
|
|
||||||
// Finish up the current frame, print some stats
|
// Finish up the current frame, print some stats
|
||||||
|
glEnable(GL_BLEND);
|
||||||
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
|
// Reset viewport for drawing text
|
||||||
|
glViewport(0, 0, GLInterface->GetBackBufferWidth(), GLInterface->GetBackBufferHeight());
|
||||||
|
DrawDebugText();
|
||||||
|
|
||||||
|
// Do our OSD callbacks
|
||||||
|
OSD::DoCallbacks(OSD::CallbackType::OnFrame);
|
||||||
|
OSD::DrawMessages();
|
||||||
|
|
||||||
|
// Copy the rendered frame to the real window.
|
||||||
|
GLInterface->Swap();
|
||||||
|
|
||||||
|
#ifdef ANDROID
|
||||||
|
// Handle surface changes on Android.
|
||||||
|
if (m_surface_needs_change.IsSet())
|
||||||
|
{
|
||||||
|
GLInterface->UpdateHandle(m_new_surface_handle);
|
||||||
|
GLInterface->UpdateSurface();
|
||||||
|
m_new_surface_handle = nullptr;
|
||||||
|
m_surface_needs_change.Clear();
|
||||||
|
m_surface_changed.Set();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Update the render window position and the backbuffer size
|
||||||
SetWindowSize(xfb_texture->GetConfig().width, xfb_texture->GetConfig().height);
|
SetWindowSize(xfb_texture->GetConfig().width, xfb_texture->GetConfig().height);
|
||||||
|
GLInterface->Update();
|
||||||
|
|
||||||
GLInterface->Update(); // just updates the render window position and the backbuffer size
|
// Was the size changed since the last frame?
|
||||||
|
|
||||||
bool window_resized = false;
|
bool window_resized = false;
|
||||||
int window_width = static_cast<int>(std::max(GLInterface->GetBackBufferWidth(), 1u));
|
int window_width = static_cast<int>(std::max(GLInterface->GetBackBufferWidth(), 1u));
|
||||||
int window_height = static_cast<int>(std::max(GLInterface->GetBackBufferHeight(), 1u));
|
int window_height = static_cast<int>(std::max(GLInterface->GetBackBufferHeight(), 1u));
|
||||||
|
@ -1404,33 +1430,6 @@ void Renderer::SwapImpl(AbstractTexture* texture, const EFBRectangle& xfb_region
|
||||||
BoundingBox::SetTargetSizeChanged(m_target_width, m_target_height);
|
BoundingBox::SetTargetSizeChanged(m_target_width, m_target_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
|
||||||
glEnable(GL_BLEND);
|
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
||||||
|
|
||||||
// Reset viewport for drawing text
|
|
||||||
glViewport(0, 0, GLInterface->GetBackBufferWidth(), GLInterface->GetBackBufferHeight());
|
|
||||||
|
|
||||||
DrawDebugText();
|
|
||||||
|
|
||||||
// Do our OSD callbacks
|
|
||||||
OSD::DoCallbacks(OSD::CallbackType::OnFrame);
|
|
||||||
OSD::DrawMessages();
|
|
||||||
|
|
||||||
#ifdef ANDROID
|
|
||||||
if (m_surface_needs_change.IsSet())
|
|
||||||
{
|
|
||||||
GLInterface->UpdateHandle(m_new_surface_handle);
|
|
||||||
GLInterface->UpdateSurface();
|
|
||||||
m_new_surface_handle = nullptr;
|
|
||||||
m_surface_needs_change.Clear();
|
|
||||||
m_surface_changed.Set();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Copy the rendered frame to the real window
|
|
||||||
GLInterface->Swap();
|
|
||||||
|
|
||||||
// Clear framebuffer
|
// Clear framebuffer
|
||||||
glClearColor(0, 0, 0, 0);
|
glClearColor(0, 0, 0, 0);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
Loading…
Reference in New Issue