我是glsl着色器语言和lwjgl的新手。我只是将这个程序汇总在一起,着色器将无法编译。它不输出着色器日志,我不知道出了什么问题。 着色器加载器(它抛出错误):
s <- strsplit(gsub("\\[|\\]|\\'","",df$ayjid),", ",fixed = TRUE)
res <- data.frame(Id = rep(df$Id, lengths(s)), result = unlist(s))
merge(df,res)
这是我的基本顶点着色器(正在编译的那个):
public static int generateShader(String shaderFile, int type)
{
StringBuilder shaderSource = new StringBuilder();
try
{
BufferedReader reader = new BufferedReader(new FileReader("res/shaders/" + shaderFile));
String line;
while ((line = reader.readLine()) != null)
{
shaderSource.append(line + "\n");
}
reader.close();
} catch (IOException e)
{
e.printStackTrace();
System.exit(1);
}
int shaderId = GL20.glCreateShader(type);
GL20.glShaderSource(shaderId, shaderSource.toString());
GL20.glCompileShader(shaderId);
if(GL20.glGetShaderi(shaderId, GL20.GL_COMPILE_STATUS) == 0)
{
System.out.println(GL20.glGetShaderInfoLog(shaderId, 1000));
System.err.println("Could not compile shader");
System.exit(1);
}
return shaderId;
}
以下是我存储着色器的方法:
#version 400 core
in vec3 position;
out vec3 color;
void main(void)
{
gl_position = vec4(position, 1);
color = position;
}
当我调用loadVertex时出错。正如我之前所说,没有java错误,着色器信息日志为空。