diff options
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shaders.h | 8 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/renderer_opengl.cpp | 14 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/renderer_opengl.h | 3 |
3 files changed, 15 insertions, 10 deletions
diff --git a/src/video_core/renderer_opengl/gl_shaders.h b/src/video_core/renderer_opengl/gl_shaders.h index f84424c47..380648f45 100644 --- a/src/video_core/renderer_opengl/gl_shaders.h +++ b/src/video_core/renderer_opengl/gl_shaders.h | |||
| @@ -7,9 +7,9 @@ | |||
| 7 | namespace GLShaders { | 7 | namespace GLShaders { |
| 8 | 8 | ||
| 9 | static const char g_vertex_shader[] = R"( | 9 | static const char g_vertex_shader[] = R"( |
| 10 | #version 330 core | 10 | #version 150 core |
| 11 | layout(location = 0) in vec3 position; | 11 | in vec3 position; |
| 12 | layout(location = 1) in vec2 texCoord; | 12 | in vec2 texCoord; |
| 13 | 13 | ||
| 14 | out vec2 UV; | 14 | out vec2 UV; |
| 15 | 15 | ||
| @@ -27,7 +27,7 @@ void main() { | |||
| 27 | })"; | 27 | })"; |
| 28 | 28 | ||
| 29 | static const char g_fragment_shader[] = R"( | 29 | static const char g_fragment_shader[] = R"( |
| 30 | #version 330 core | 30 | #version 150 core |
| 31 | in vec2 UV; | 31 | in vec2 UV; |
| 32 | out vec3 color; | 32 | out vec3 color; |
| 33 | uniform sampler2D sampler; | 33 | uniform sampler2D sampler; |
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index 6470245e6..ce90a9754 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp | |||
| @@ -155,6 +155,8 @@ void RendererOpenGL::RenderXFB(const common::Rect& src_rect, const common::Rect& | |||
| 155 | void RendererOpenGL::InitFramebuffer() { | 155 | void RendererOpenGL::InitFramebuffer() { |
| 156 | program_id = ShaderUtil::LoadShaders(GLShaders::g_vertex_shader, GLShaders::g_fragment_shader); | 156 | program_id = ShaderUtil::LoadShaders(GLShaders::g_vertex_shader, GLShaders::g_fragment_shader); |
| 157 | sampler_id = glGetUniformLocation(program_id, "sampler"); | 157 | sampler_id = glGetUniformLocation(program_id, "sampler"); |
| 158 | attrib_position = glGetAttribLocation(program_id, "position"); | ||
| 159 | attrib_texcoord = glGetAttribLocation(program_id, "texCoord"); | ||
| 158 | 160 | ||
| 159 | // Generate vertex buffers for both screens | 161 | // Generate vertex buffers for both screens |
| 160 | glGenBuffers(1, &screen_info.Top().vertex_buffer_id); | 162 | glGenBuffers(1, &screen_info.Top().vertex_buffer_id); |
| @@ -197,8 +199,8 @@ void RendererOpenGL::RenderFramebuffer() { | |||
| 197 | // Bind texture in Texture Unit 0 | 199 | // Bind texture in Texture Unit 0 |
| 198 | glActiveTexture(GL_TEXTURE0); | 200 | glActiveTexture(GL_TEXTURE0); |
| 199 | 201 | ||
| 200 | glEnableVertexAttribArray(0); | 202 | glEnableVertexAttribArray(attrib_position); |
| 201 | glEnableVertexAttribArray(1); | 203 | glEnableVertexAttribArray(attrib_texcoord); |
| 202 | 204 | ||
| 203 | for (int i = 0; i < 2; i++) { | 205 | for (int i = 0; i < 2; i++) { |
| 204 | 206 | ||
| @@ -216,15 +218,15 @@ void RendererOpenGL::RenderFramebuffer() { | |||
| 216 | const GLvoid* uv_offset = (const GLvoid*)(3 * sizeof(GLfloat)); | 218 | const GLvoid* uv_offset = (const GLvoid*)(3 * sizeof(GLfloat)); |
| 217 | 219 | ||
| 218 | // Configure vertex buffer | 220 | // Configure vertex buffer |
| 219 | glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, stride, NULL); | 221 | glVertexAttribPointer(attrib_position, 3, GL_FLOAT, GL_FALSE, stride, NULL); |
| 220 | glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, stride, uv_offset); | 222 | glVertexAttribPointer(attrib_texcoord, 2, GL_FLOAT, GL_FALSE, stride, uv_offset); |
| 221 | 223 | ||
| 222 | // Draw screen | 224 | // Draw screen |
| 223 | glDrawArrays(GL_TRIANGLES, 0, 6); | 225 | glDrawArrays(GL_TRIANGLES, 0, 6); |
| 224 | } | 226 | } |
| 225 | 227 | ||
| 226 | glDisableVertexAttribArray(0); | 228 | glDisableVertexAttribArray(attrib_position); |
| 227 | glDisableVertexAttribArray(1); | 229 | glDisableVertexAttribArray(attrib_texcoord); |
| 228 | 230 | ||
| 229 | m_current_frame++; | 231 | m_current_frame++; |
| 230 | } | 232 | } |
diff --git a/src/video_core/renderer_opengl/renderer_opengl.h b/src/video_core/renderer_opengl/renderer_opengl.h index 423467e4c..e90fa0c77 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.h +++ b/src/video_core/renderer_opengl/renderer_opengl.h | |||
| @@ -85,6 +85,9 @@ private: | |||
| 85 | GLuint vertex_array_id; | 85 | GLuint vertex_array_id; |
| 86 | GLuint program_id; | 86 | GLuint program_id; |
| 87 | GLuint sampler_id; | 87 | GLuint sampler_id; |
| 88 | // Shader attribute input indices | ||
| 89 | GLuint attrib_position; | ||
| 90 | GLuint attrib_texcoord; | ||
| 88 | 91 | ||
| 89 | struct : std::array<ScreenInfo, 2> { | 92 | struct : std::array<ScreenInfo, 2> { |
| 90 | ScreenInfo& Top() { return (*this)[0]; } | 93 | ScreenInfo& Top() { return (*this)[0]; } |