mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-11 21:58:31 +09:00
[Feat] (MG_Test/Program): Test for GetAttribLocation/BindAttribLocation
This commit is contained in:
@@ -23,8 +23,13 @@ TEST_F(ProgramTest, Sanity) {
|
|||||||
|
|
||||||
const char* vsSrc = R"(#version 460
|
const char* vsSrc = R"(#version 460
|
||||||
|
|
||||||
in vec4 Position;
|
layout (location = 0) in vec4 Position;
|
||||||
in float fIn;
|
in float fIn4;
|
||||||
|
in float fIn2;
|
||||||
|
in float fIn5;
|
||||||
|
in float fIn6;
|
||||||
|
in float fIn1;
|
||||||
|
in float fIn3;
|
||||||
|
|
||||||
layout(location = 0) uniform mat4 ProjMat;
|
layout(location = 0) uniform mat4 ProjMat;
|
||||||
uniform vec2 InSize;
|
uniform vec2 InSize;
|
||||||
@@ -37,7 +42,7 @@ void main(){
|
|||||||
vec4 outPos = ProjMat * vec4(Position.xy, 0.0, 1.0);
|
vec4 outPos = ProjMat * vec4(Position.xy, 0.0, 1.0);
|
||||||
gl_Position = vec4(outPos.xy, 0.2, 1.0);
|
gl_Position = vec4(outPos.xy, 0.2, 1.0);
|
||||||
|
|
||||||
oneTexel = (1.0 * fIn) / InSize;
|
oneTexel = (1.0 * (fIn1 * fIn2 * fIn3 * fIn4 * fIn5 * fIn6)) / InSize;
|
||||||
|
|
||||||
texCoord = Position.xy / OutSize;
|
texCoord = Position.xy / OutSize;
|
||||||
})";
|
})";
|
||||||
@@ -111,6 +116,10 @@ TEST_F(ProgramTest, CompileAndLink) {
|
|||||||
GLuint program = CreateProgram();
|
GLuint program = CreateProgram();
|
||||||
AttachShader(program, vs);
|
AttachShader(program, vs);
|
||||||
AttachShader(program, fs);
|
AttachShader(program, fs);
|
||||||
|
|
||||||
|
BindAttribLocation(program, 1, "fIn1");
|
||||||
|
BindAttribLocation(program, 3, "fIn3");
|
||||||
|
BindAttribLocation(program, 5, "fIn5");
|
||||||
printf("Linking program...\n");
|
printf("Linking program...\n");
|
||||||
LinkProgram(program);
|
LinkProgram(program);
|
||||||
printf("Program linked.\n");
|
printf("Program linked.\n");
|
||||||
@@ -124,4 +133,9 @@ TEST_F(ProgramTest, CompileAndLink) {
|
|||||||
GLint uniformNameMaxLength = 0;
|
GLint uniformNameMaxLength = 0;
|
||||||
GetProgramiv(program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &uniformNameMaxLength);
|
GetProgramiv(program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &uniformNameMaxLength);
|
||||||
EXPECT_EQ(uniformNameMaxLength, 12);
|
EXPECT_EQ(uniformNameMaxLength, 12);
|
||||||
|
|
||||||
|
EXPECT_EQ(GetAttribLocation(program, "Position"), 0);
|
||||||
|
EXPECT_EQ(GetAttribLocation(program, "fIn1"), 1);
|
||||||
|
EXPECT_EQ(GetAttribLocation(program, "fIn3"), 3);
|
||||||
|
EXPECT_EQ(GetAttribLocation(program, "fIn5"), 5);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user