2
1
Fork 0
mirror of https://github.com/yuzu-emu/yuzu.git synced 2024-07-04 23:31:19 +01:00

gl_shader_gen: Use explicit locations for vertex shader attributes.

This commit is contained in:
bunnei 2015-10-21 21:50:55 -04:00
parent e663f5c914
commit 74186a5f01
2 changed files with 8 additions and 14 deletions

View file

@ -362,15 +362,14 @@ out vec4 color;
} }
std::string GenerateVertexShader() { std::string GenerateVertexShader() {
static const std::string out = R"( std::string out = "#version 330\n";
#version 330 out += "layout(location = " + std::to_string((int)ATTRIBUTE_POSITION) + ") in vec4 vert_position;\n";
out += "layout(location = " + std::to_string((int)ATTRIBUTE_COLOR) + ") in vec4 vert_color;\n";
in vec4 vert_position; out += "layout(location = " + std::to_string((int)ATTRIBUTE_TEXCOORD0) + ") in vec2 vert_texcoord0;\n";
in vec4 vert_color; out += "layout(location = " + std::to_string((int)ATTRIBUTE_TEXCOORD1) + ") in vec2 vert_texcoord1;\n";
in vec2 vert_texcoord0; out += "layout(location = " + std::to_string((int)ATTRIBUTE_TEXCOORD2) + ") in vec2 vert_texcoord2;\n";
in vec2 vert_texcoord1;
in vec2 vert_texcoord2;
out += R"(
out vec4 primary_color; out vec4 primary_color;
out vec2 texcoord[3]; out vec2 texcoord[3];
@ -382,6 +381,7 @@ void main() {
gl_Position = vec4(vert_position.x, -vert_position.y, -vert_position.z, vert_position.w); gl_Position = vec4(vert_position.x, -vert_position.y, -vert_position.z, vert_position.w);
} }
)"; )";
return out; return out;
} }

View file

@ -66,12 +66,6 @@ GLuint LoadProgram(const char* vertex_shader, const char* fragment_shader) {
glAttachShader(program_id, vertex_shader_id); glAttachShader(program_id, vertex_shader_id);
glAttachShader(program_id, fragment_shader_id); glAttachShader(program_id, fragment_shader_id);
glBindAttribLocation(program_id, Attributes::ATTRIBUTE_POSITION, "vert_position");
glBindAttribLocation(program_id, Attributes::ATTRIBUTE_COLOR, "vert_color");
glBindAttribLocation(program_id, Attributes::ATTRIBUTE_TEXCOORD0, "vert_texcoord0");
glBindAttribLocation(program_id, Attributes::ATTRIBUTE_TEXCOORD1, "vert_texcoord1");
glBindAttribLocation(program_id, Attributes::ATTRIBUTE_TEXCOORD2, "vert_texcoord2");
glLinkProgram(program_id); glLinkProgram(program_id);
// Check the program // Check the program