diff options
| author | iwubcode <iwubcode@users.noreply.github.com> | 2017-08-23 21:46:23 -0500 |
|---|---|---|
| committer | iwubcode <iwubcode@users.noreply.github.com> | 2017-11-17 22:11:31 -0600 |
| commit | 6e686f6ea10c486a6271a6ca7cd084e124776b5a (patch) | |
| tree | 55e0c3ae1a9735b4b80515a6dc60f72bebcd726e /Source/Core/VideoBackends/Software/SWOGLWindow.cpp | |
| parent | e6d85b0915681a3f8162d45468f2c488d6df8114 (diff) | |
Software Backend: Fix xfb output and add vertical scaling support
Diffstat (limited to 'Source/Core/VideoBackends/Software/SWOGLWindow.cpp')
| -rw-r--r-- | Source/Core/VideoBackends/Software/SWOGLWindow.cpp | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/Source/Core/VideoBackends/Software/SWOGLWindow.cpp b/Source/Core/VideoBackends/Software/SWOGLWindow.cpp index 52b2fb02cd..372f15322e 100644 --- a/Source/Core/VideoBackends/Software/SWOGLWindow.cpp +++ b/Source/Core/VideoBackends/Software/SWOGLWindow.cpp @@ -9,7 +9,7 @@ #include "Common/Logging/Log.h" #include "VideoBackends/Software/SWOGLWindow.h" -#include "VideoCommon/AbstractTexture.h" +#include "VideoBackends/Software/SWTexture.h" std::unique_ptr<SWOGLWindow> SWOGLWindow::s_instance; @@ -54,9 +54,9 @@ void SWOGLWindow::Prepare() std::string frag_shader = "in vec2 TexCoord;\n" "out vec4 ColorOut;\n" - "uniform sampler2DArray samp;\n" + "uniform sampler2D samp;\n" "void main() {\n" - " ColorOut = texture(samp, vec3(TexCoord, 0.0));\n" + " ColorOut = texture(samp, TexCoord);\n" "}\n"; std::string vertex_shader = "out vec2 TexCoord;\n" @@ -76,8 +76,11 @@ void SWOGLWindow::Prepare() glUseProgram(m_image_program); glUniform1i(glGetUniformLocation(m_image_program, "samp"), 0); + glGenTextures(1, &m_image_texture); + glBindTexture(GL_TEXTURE_2D, m_image_texture); - glPixelStorei(GL_UNPACK_ALIGNMENT, 4); // 4-byte pixel alignment + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glGenVertexArrays(1, &m_image_vao); } @@ -89,6 +92,7 @@ void SWOGLWindow::PrintText(const std::string& text, int x, int y, u32 color) void SWOGLWindow::ShowImage(AbstractTexture* image, float aspect) { + SW::SWTexture * sw_image = static_cast<SW::SWTexture*>(image); GLInterface->Update(); // just updates the render window position and the backbuffer size GLsizei glWidth = (GLsizei)GLInterface->GetBackBufferWidth(); @@ -96,10 +100,15 @@ void SWOGLWindow::ShowImage(AbstractTexture* image, float aspect) glViewport(0, 0, glWidth, glHeight); - image->Bind(0); + glActiveTexture(GL_TEXTURE9); + glBindTexture(GL_TEXTURE_2D, m_image_texture); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glPixelStorei(GL_UNPACK_ALIGNMENT, 4); // 4-byte pixel alignment + glPixelStorei(GL_UNPACK_ROW_LENGTH, sw_image->GetConfig().width); + + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, static_cast<GLsizei>(sw_image->GetConfig().width), + static_cast<GLsizei>(sw_image->GetConfig().height), 0, GL_RGBA, GL_UNSIGNED_BYTE, + sw_image->GetData()); glUseProgram(m_image_program); |
