diff options
author | Yuri Kunde Schlesner <yuriks@yuriks.net> | 2014-08-28 10:37:07 +0200 |
---|---|---|
committer | Yuri Kunde Schlesner <yuriks@yuriks.net> | 2014-08-28 10:38:13 +0200 |
commit | 9d172ab5501ba76be59f38bbff746f7ac51eb5ce (patch) | |
tree | 8cd2c35d874178fdb823af40d89979c4a2cd647d /src/video_core/renderer_opengl | |
parent | Merge pull request #79 from bunnei/framebuffer-render-fixes (diff) | |
download | yuzu-9d172ab5501ba76be59f38bbff746f7ac51eb5ce.tar yuzu-9d172ab5501ba76be59f38bbff746f7ac51eb5ce.tar.gz yuzu-9d172ab5501ba76be59f38bbff746f7ac51eb5ce.tar.bz2 yuzu-9d172ab5501ba76be59f38bbff746f7ac51eb5ce.tar.lz yuzu-9d172ab5501ba76be59f38bbff746f7ac51eb5ce.tar.xz yuzu-9d172ab5501ba76be59f38bbff746f7ac51eb5ce.tar.zst yuzu-9d172ab5501ba76be59f38bbff746f7ac51eb5ce.zip |
Diffstat (limited to 'src/video_core/renderer_opengl')
-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 @@ namespace GLShaders { static const char g_vertex_shader[] = R"( -#version 330 core -layout(location = 0) in vec3 position; -layout(location = 1) in vec2 texCoord; +#version 150 core +in vec3 position; +in vec2 texCoord; out vec2 UV; @@ -27,7 +27,7 @@ void main() { })"; static const char g_fragment_shader[] = R"( -#version 330 core +#version 150 core in vec2 UV; out vec3 color; 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& void RendererOpenGL::InitFramebuffer() { program_id = ShaderUtil::LoadShaders(GLShaders::g_vertex_shader, GLShaders::g_fragment_shader); sampler_id = glGetUniformLocation(program_id, "sampler"); + attrib_position = glGetAttribLocation(program_id, "position"); + attrib_texcoord = glGetAttribLocation(program_id, "texCoord"); // Generate vertex buffers for both screens glGenBuffers(1, &screen_info.Top().vertex_buffer_id); @@ -197,8 +199,8 @@ void RendererOpenGL::RenderFramebuffer() { // Bind texture in Texture Unit 0 glActiveTexture(GL_TEXTURE0); - glEnableVertexAttribArray(0); - glEnableVertexAttribArray(1); + glEnableVertexAttribArray(attrib_position); + glEnableVertexAttribArray(attrib_texcoord); for (int i = 0; i < 2; i++) { @@ -216,15 +218,15 @@ void RendererOpenGL::RenderFramebuffer() { const GLvoid* uv_offset = (const GLvoid*)(3 * sizeof(GLfloat)); // Configure vertex buffer - glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, stride, NULL); - glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, stride, uv_offset); + glVertexAttribPointer(attrib_position, 3, GL_FLOAT, GL_FALSE, stride, NULL); + glVertexAttribPointer(attrib_texcoord, 2, GL_FLOAT, GL_FALSE, stride, uv_offset); // Draw screen glDrawArrays(GL_TRIANGLES, 0, 6); } - glDisableVertexAttribArray(0); - glDisableVertexAttribArray(1); + glDisableVertexAttribArray(attrib_position); + glDisableVertexAttribArray(attrib_texcoord); m_current_frame++; } 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: GLuint vertex_array_id; GLuint program_id; GLuint sampler_id; + // Shader attribute input indices + GLuint attrib_position; + GLuint attrib_texcoord; struct : std::array<ScreenInfo, 2> { ScreenInfo& Top() { return (*this)[0]; } |