我正在尝试为 3 个圆圈着色,但只出现了 3 个白色圆圈。在此示例中,n 为 3。每个顶点有 5 个点,2 个用于位置,3 个用于颜色
这是我认为可能存在问题的地方:
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
glVertexAttribPointer(
0,
2,
GL_FLOAT,
GL_FALSE,
5*sizeof(float),
(void*)0
);
glEnableVertexAttribArray(1);
glVertexAttribPointer(
1,
3,
GL_FLOAT,
GL_FALSE,
5*sizeof(float),
(void*)(2*sizeof(float))
);
glDrawElements(GL_TRIANGLES, 20 * 3 * n, GL_UNSIGNED_INT, 0);
glDisableVertexAttribArray(0);
glDisableVertexAttribArray(1);
Run Code Online (Sandbox Code Playgroud)
我的着色器:
#version 330 core
in vec3 Color;
out vec4 outColor;
void main()
{
outColor = vec4(Color, 1.0);
}
#version 330 core
layout(location = 0) in vec2 position;
layout(location = 1) in vec3 color
out vec3 Color
void main(){ …Run Code Online (Sandbox Code Playgroud) 我正在使用以下代码:
public void readLevel(int line){
AssetManager am = this.getAssets();
InputStream is = null;
try {
is = am.open("levelinfo.txt");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Scanner scanner = new Scanner(is);
scanner.useDelimiter(",");
String skip;
for(int i = 1; i < line; i++){
skip = scanner.nextLine();
}
levelData = new ArrayList<Integer>();
while(scanner.hasNextInt()){
levelData.add(scanner.nextInt());
}
}
Run Code Online (Sandbox Code Playgroud)
该代码给出了FileNotFoundException。我已经看到了一些类似的问题,但是我不确定如何解决。该文件是资产文件夹中的文本文件。任何帮助表示赞赏
安迪